Hàm is_file () kiểm tra xem tên tệp được chỉ định là tệp thông thường.
8 năm trước
Làm thế nào để kiểm tra biến tệp trong PHP? — Tells whether the filename is a regular file
print_r ($ _ files); echo "";?
PHP có phải là một thư mục hoặc tệp?(string $filename
): bool
Hàm is_dir () trong PHP được sử dụng để kiểm tra xem tệp được chỉ định có phải là thư mục hay không. Tên của tệp được gửi dưới dạng tham số cho hàm is_dir () và nó trả về true nếu tệp là một thư mục khác, nó trả về sai. Các tham số được sử dụng: Hàm is_dir () trong PHP chỉ chấp nhận một tham số.
Hàm nào xác định tên tệp có đề cập đến một tệp hay không?File_exists kiểm tra xem một tệp có tồn tại trong đường dẫn được chỉ định hay không. Trả về true nếu tệp hoặc thư mục được chỉ định bởi tên tệp tồn tại; Sai nếu không.
(Php 4, Php 5, Php 7, Php 8)
IS_FILE - cho biết tên tệp có phải là một tệp thông thường khôngtrue
if the filename exists and is a regular file, false
otherwise.
Sự mô tả: Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB.
Errors/Exceptions
IS_FILE (Chuỗi $filename
): BoolE_WARNING
is emitted.
Thông số
filename
is_file() example
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
Đường dẫn đến tệp.
Trả về giá trị
Trả về true
nếu tên tệp tồn tại và là một tệp thông thường, false
nếu không.: The results of this function are cached. See
clearstatcache() for more details.
Lưu ý: Vì loại số nguyên của PHP được ký kết và nhiều nền tảng sử dụng số nguyên 32 bit, một số hàm hệ thống tập tin có thể trả về kết quả bất ngờ cho các tệp lớn hơn 2GB.
- Khi thất bại, một
E_WARNING
được phát ra. - Ví dụ
- Ví dụ #1 is_file () ví dụ
Rehfeld.us ¶ ¶
18 năm trước
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
Rehfeld.us ¶ ¶
18 năm trước
### Symbolic links are resolved ###
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
touch file
ln -s file link
echo '<? if (is_file("link")) echo "y\n"; ?>' | php -q
filename
0
filename
1
filename
2 Ca Dot Redwood tại Gmail Dot Com ¶ ¶
18 năm trước
filename
3
filename
4
filename
2
Ca Dot Redwood tại Gmail Dot Com ¶ ¶
13 năm trước
filename
6
filename
7
filename
2 David tại Bruchmann-Web dot de ¶ ¶
Alex tại Magemore Dot Com ¶
filename
9
Rehfeld.us ¶ ¶
18 năm trước
true
0
true
1
filename
2
Ca Dot Redwood tại Gmail Dot Com ¶ ¶
13 năm trước
true
3
true
4
true
5
true
6
filename
2 David tại Bruchmann-Web dot de ¶ ¶
19 năm trước
true
8
true
9
false
0
false
1
false
2
filename
2 Rehfeld.us ¶ ¶
13 năm trước
false
4
David tại Bruchmann-Web dot de ¶ ¶
18 năm trước
false
5
Ca Dot Redwood tại Gmail Dot Com ¶ ¶
18 năm trước
false
6
false
7
filename
2 Ca Dot Redwood tại Gmail Dot Com ¶ ¶
Alex tại Magemore Dot Com ¶
false
9
6 năm trước ¶
13 năm trước
E_WARNING
0
E_WARNING
1
filename
2 David tại Bruchmann-Web dot de ¶ ¶
13 năm trước
E_WARNING
3
E_WARNING
4
E_WARNING
5
E_WARNING
6
filename
2 David tại Bruchmann-Web dot de ¶ ¶
Alex tại Magemore Dot Com ¶
E_WARNING
8
E_WARNING
9
filename
2 6 năm trước ¶
13 năm trước
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
1
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
2
filename
2 David tại Bruchmann-Web dot de ¶ ¶
Alex tại Magemore Dot Com ¶
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
4
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
5
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
6
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
7
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
8
filename
2 sarken tại miễn phí dot fr ¶ ¶
9 năm trước
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
0
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
1
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
2
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
3
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
4
filename
2 RLH tại d8acom dot com ¶ ¶
19 năm trước
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
6
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
7
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
8
Note that is_file() returns false if the parent directory doesn't have +x set for you; this make sense, but other functions such as readdir() don't seem to have this limitation. The end result is that you can loop through a directory's files but is_file() will always fail.
9
filename
2 Rehfeld.us ¶ ¶
18 năm trước
### Symbolic links are resolved ###
1
### Symbolic links are resolved ###
2
### Symbolic links are resolved ###
3
### Symbolic links are resolved ###
4
### Symbolic links are resolved ###
5
### Symbolic links are resolved ###
6
### Symbolic links are resolved ###
7
### Symbolic links are resolved ###
8 Ca Dot Redwood tại Gmail Dot Com ¶ ¶
13 năm trước
### Symbolic links are resolved ###
9
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
0
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
1
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
2 David tại Bruchmann-Web dot de ¶ ¶
9 năm trước
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
3
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
4
filename
2 RLH tại d8acom dot com ¶ ¶
19 năm trước
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
6
Rehfeld.us ¶ ¶
18 năm trước
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
7
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
8
If you pass a symlink (unix symbolic link) as parameter, is_file will resolve the symlink and will give information about the refered file. For example:
9
touch file
ln -s file link
echo '<? if (is_file("link")) echo "y\n"; ?>' | php -q
0File_exists kiểm tra xem một tệp có tồn tại trong đường dẫn được chỉ định hay không.Trả về true nếu tệp hoặc thư mục được chỉ định bởi tên tệp tồn tại;Sai nếu không.