Hướng dẫn is_file in php - is_file trong php

(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ôngTells whether the filename is a regular file

Sự mô tả

IS_FILE (Chuỗi $filename): Bool(string $filename): bool

Thông số

filename

Đườ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.true if the filename exists and is a regular file, false otherwise.

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.: 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

Khi thất bại, một E_WARNING được phát ra.E_WARNING is emitted.

Ví dụ

Ví dụ #1 is_file () ví dụis_file() example

var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>

Ví dụ trên sẽ xuất ra:

Ghi chú

Lưu ý: Kết quả của chức năng này được lưu trong bộ nhớ cache. Xem ClearStatCache () để biết thêm chi tiết.: The results of this function are cached. See clearstatcache() for more details.

Xem thêm

  • is_dir () - cho biết tên tệp có phải là thư mục
  • is_link () - cho biết liệu tên tệp có phải là liên kết tượng trưng
  • Splfileinfo

Ẩn danh ¶

10 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.

Ẩn danh ¶

10 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 '' | php -q

filename0

filename1

filename2

17 năm trước

10 năm trước

filename3

filename4

filename2

17 năm trước

Ludvig dot ericson tại gmail dot com ¶

filename6

filename7

filename2

Gizmo tại Gizmo Dot SK ¶

14 năm trước

filename9

Ẩn danh ¶

10 năm trước

true0

true1

filename2

17 năm trước

Ludvig dot ericson tại gmail dot com ¶

true3

true4

true5

true6

filename2

Gizmo tại Gizmo Dot SK ¶

14 năm trước

true8

true9

false0

false1

false2

filename2

Andreas Dot Stagl ở Fits Dot tại ¶

Ludvig dot ericson tại gmail dot com ¶

false4

Gizmo tại Gizmo Dot SK ¶

14 năm trước

false5

Andreas Dot Stagl ở Fits Dot tại ¶

10 năm trước

false6

false7

filename2

17 năm trước

14 năm trước

false9

Andreas Dot Stagl ở Fits Dot tại ¶

20 năm trước

E_WARNING0

E_WARNING1

filename2

11 năm trước

20 năm trước

E_WARNING3

E_WARNING4

E_WARNING5

E_WARNING6

filename2

11 năm trước

Cristian Dot Ban tại Neobytesolutions com ¶

E_WARNING8

E_WARNING9

filename2

15 năm trước

Ludvig dot ericson tại gmail dot com ¶

var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
1

var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
2

filename2

Gizmo tại Gizmo Dot SK ¶

Ludvig dot ericson tại gmail dot com ¶

var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
4

var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
5

var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
6

var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
7

var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>
8

filename2

Gizmo tại Gizmo Dot SK ¶

14 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

Andreas Dot Stagl ở Fits Dot tại ¶

20 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

11 năm trước

Cristian Dot Ban tại Neobytesolutions com ¶

### 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

15 năm trước

20 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

11 năm trước

14 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

Andreas Dot Stagl ở Fits Dot tại ¶

14 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

Ẩn danh ¶

10 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 '' | php -q
0