Hướng dẫn what is is_file function in php? - hàm is_file trong php là gì?

❮ Tham chiếu hệ thống tập tin PHP

Thí dụ

Kiểm tra xem tên tệp được chỉ định là tệp thông thường:

$file = "test.txt";
if(is_file($file)) {
  echo ("$file is a regular file");
} else {
  echo ("$file is not a regular file");
}
?>

Đầu ra của mã ở trên có thể là:

test.txt là một tệp thông thường



Định nghĩa và cách sử dụng

Hàm is_file () kiểm tra xem tên tệp được chỉ định là tệp thông thường.

Lưu ý: Kết quả của chức năng này được lưu trong bộ nhớ cache. Sử dụng ClearStatCache () để xóa bộ đệm. & Nbsp; The result of this function is cached. Use clearstatcache() to clear the cache. 

Cú pháp

Giá trị tham số

Tham sốSự mô tả
tập tinYêu cầu. Chỉ định đường dẫn đến tệp để kiểm tra


Chi tiết kỹ thuật

Giá trị trở lại:Đúng nếu tệp là một tệp thông thường, mặt khác
Phiên bản PHP:4.0+

❮ Tham chiếu hệ thống tập tin PHP


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

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ố

filenameis_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

filename0

filename1

filename2

Ca Dot Redwood tại Gmail Dot Com ¶

18 năm trước

filename3

filename4

filename2

Ca Dot Redwood tại Gmail Dot Com ¶

13 năm trước

filename6

filename7

filename2

David tại Bruchmann-Web dot de ¶

Alex tại Magemore Dot Com ¶

filename9

Rehfeld.us ¶

18 năm trước

true0

true1

filename2

Ca Dot Redwood tại Gmail Dot Com ¶

13 năm trước

true3

true4

true5

true6

filename2

David tại Bruchmann-Web dot de ¶

19 năm trước

true8

true9

false0

false1

false2

filename2

Rehfeld.us ¶

13 năm trước

false4

David tại Bruchmann-Web dot de ¶

18 năm trước

false5

Ca Dot Redwood tại Gmail Dot Com ¶

18 năm trước

false6

false7

filename2

Ca Dot Redwood tại Gmail Dot Com ¶

Alex tại Magemore Dot Com ¶

false9

6 năm trước

13 năm trước

E_WARNING0

E_WARNING1

filename2

David tại Bruchmann-Web dot de ¶

13 năm trước

E_WARNING3

E_WARNING4

E_WARNING5

E_WARNING6

filename2

David tại Bruchmann-Web dot de ¶

Alex tại Magemore Dot Com ¶

E_WARNING8

E_WARNING9

filename2

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

filename2

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

filename2

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

filename2

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

filename2

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

filename2

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
0

Làm thế nào để kiểm tra biến tệp trong PHP?

print_r ($ _ files); echo "";? echo ""; ?> Once when we select the file and upload then the function print_r will display the information of the PHP superglobal associative array $_FILES.

PHP có phải là một thư mục hoặc tệp?

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ố.. The name of the file is sent as a parameter to the is_dir() function and it returns True if the file is a directory else it returns False. Parameters Used: The is_dir() function in PHP accepts only one parameter.

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.