Hướng dẫn is php a directory or file? - php là thư mục hay tệp tin?

(Php 4, Php 5, Php 7, Php 8)

IS_DIR - cho biết tên tệp có phải là thư mục khôngTells whether the filename is a directory

Sự mô tả

is_dir (chuỗi $filename): bool(string $filename): bool

Thông số

filename

Đường dẫn đến tệp. Nếu filename là tên tệp tương đối, nó sẽ được kiểm tra liên quan đến thư mục làm việc hiện tại. Nếu filename là một liên kết tượng trưng hoặc cứng thì liên kết sẽ được giải quyết và kiểm tra. Nếu bạn đã kích hoạt các hạn chế thêm Open_basingir có thể áp dụng.

Trả về giá trị

Trả về true nếu tên tệp tồn tại và là một thư mục, false nếu không.true if the filename exists and is a directory, false otherwise.

Errors/Exceptions

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

Ví dụ

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

<?php
var_dump
(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));var_dump(is_dir('..')); //one dir up
?>

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

bool(false)
bool(false)
bool(true)

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

  • CHDIR () - Thay đổi thư mục
  • Dir () - Trả về một thể hiện của lớp thư mục
  • opendir () - tay cầm thư mục mở
  • is_file () - cho biết liệu tên tệp có phải là tệp thông thường không
  • is_link () - cho biết liệu tên tệp có phải là liên kết tượng trưng

DigitalAudiorock tại Gmail Dot Com ¶

12 năm trước

Just a note for anyone who encounters is_dir() returning false on CIFS mount points or directories within those mount points on 2.6.31 and newer kernels: Apparently in new kernels they've started using the CIFS serverino option by default.  With Windows shares this causes huge inode numbers and which apparently can cause is_dir() to return false.  Adding the noserverino option to the CIFS mount will prevent this.  This may only occur on 32 systems but I don't have a 64 bit install to test against.

Thomas tại Thomasnoest dot nl ¶

6 năm trước

$filename0

Sly tại noiretblanc dot org ¶

18 năm trước

$filename1

$filename2

$filename3

$filename4

$filename5

$filename6

jonlulf tại gmail dot com ¶

7 năm trước

$filename7

$filename8

$filename9

$filename6

Ẩn danh ¶

14 năm trước

filename1

Bjrn K.

6 năm trước

filename2

filename3

filename4

filename5

$filename6

Sly tại noiretblanc dot org ¶

18 năm trước

filename7

filename8

filename9

filename0

filename1

filename2

$filename6

jonlulf tại gmail dot com ¶

7 năm trước

filename4

filename5

filename6

filename7

Ẩn danh ¶

14 năm trước

filename8

filename9

filename0

filename1

filename2

filename3

filename4

filename5

filename6

filename7

filename8

filename9

$filename6

Bjrn K.

18 năm trước

true1

true2

true3

true4

$filename6

jonlulf tại gmail dot com ¶

18 năm trước

true6

true7

$filename6

jonlulf tại gmail dot com ¶

6 năm trước

true9

false0

false1

false2

false3

false4

$filename6

Sly tại noiretblanc dot org ¶

18 năm trước

false6

false7

false8

false9

$filename6

jonlulf tại gmail dot com ¶

18 năm trước

E_WARNING1

E_WARNING2

$filename6

jonlulf tại gmail dot com ¶

14 năm trước

E_WARNING4

E_WARNING5

$filename6

Bjrn K.

14 năm trước

E_WARNING7

Bjrn K.

14 năm trước

E_WARNING8

E_WARNING9

<?php
var_dump
(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));var_dump(is_dir('..')); //one dir up
?>
0

<?php
var_dump
(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));var_dump(is_dir('..')); //one dir up
?>
1

$filename6

Bjrn K.

7 năm trước

<?php
var_dump
(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));var_dump(is_dir('..')); //one dir up
?>
3

<?php
var_dump
(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));var_dump(is_dir('..')); //one dir up
?>
4

$filename6

Ẩn danh ¶

18 năm trước

<?php
var_dump
(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));var_dump(is_dir('..')); //one dir up
?>
6

<?php
var_dump
(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));var_dump(is_dir('..')); //one dir up
?>
7

<?php
var_dump
(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));var_dump(is_dir('..')); //one dir up
?>
8

jonlulf tại gmail dot com ¶

PHP có phải là một thư mục không?

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.

Tệp và thư mục trong PHP là gì?

Các chức năng thư mục PHP như tên của chúng cho thấy là một tập hợp các chức năng được sử dụng để truy xuất các chi tiết, sửa đổi chúng và tìm nạp thông tin về các thư mục hệ thống tệp khác nhau và nội dung cụ thể của chúng.a set of functions used in retrieving details, modifying them and fetching information on various file system directories and their specific contents.

Là một tập tin PHP?

Hàm is_file () trong PHP là hàm sẵn được sử dụng để kiểm tra xem tệp được chỉ định có phải là tệp thông thường hay không.Tên của tệp được gửi dưới dạng tham số cho hàm is_file () và nó trả về true nếu tệp là một tệp thông thường khác, nó trả về sai.. The name of the file is sent as a parameter to the is_file() function and it returns True if the file is a regular file else it returns False.

Tên thư mục PHP là gì?

Sử dụng hàm getcwd () để lấy tên thư mục hiện tại trong PHP.Hàm getcwd () cung cấp thư mục làm việc hiện tại.Giá trị trả về là một chuỗi trên thành công.Hàm không lấy bất kỳ tham số nào.Hàm trả về sai trong trường hợp thất bại.. The getcwd() function gives the current working directory. The returned value is a string on success. The function does not take any parameters. The function returns false in case of failure.