Hướng dẫn write the files and path properties in php - viết các tệp và thuộc tính đường dẫn trong php

Mục lục

  • Basename - Trả về thành phần tên dấu vết của đường dẫn
  • CHGRP - Thay đổi nhóm tệp
  • Chmod - Thay đổi chế độ tệp
  • Chown - Thay đổi chủ sở hữu tệp
  • ClearStatCache - Xóa bộ đệm trạng thái tệp
  • Sao chép - Tệp bản sao
  • Xóa - xem Unlink hoặc UndT
  • Dirname - Trả về đường dẫn của thư mục cha mẹ
  • DISK_FREE_SPACE - Trả về không gian có sẵn trên hệ thống tập tin hoặc phân vùng đĩa
  • DISK_TOTAL_SPACE - Trả về tổng kích thước của hệ thống tập tin hoặc phân vùng đĩa
  • Không gian đĩa - Bí danh của disk_free_space
  • FCLOSE - Đóng một con trỏ tệp mở
  • fdatasync-đồng bộ hóa dữ liệu (nhưng không phải là dữ liệu meta) với tệp
  • FOEF-Các bài kiểm tra cho phần cuối trên một con trỏ tệp
  • FFLUSH - Xóa đầu ra vào một tệp
  • FGETC - Nhận ký tự từ con trỏ tệp
  • FGETCSV - Nhận dòng từ con trỏ tệp và phân tích cho các trường CSV
  • FGETS - Nhận dòng từ con trỏ tệp
  • FGETSS - Nhận dòng từ con trỏ tệp và thẻ HTML dải
  • file_exists - kiểm tra xem một tệp hoặc thư mục có tồn tại không
  • file_get_contents - đọc toàn bộ tệp thành một chuỗi
  • file_put_contents - ghi dữ liệu vào một tệp
  • Tệp - Đọc toàn bộ tệp vào một mảng
  • Fileatime - Nhận thời gian truy cập cuối cùng của tệp
  • Filectime - Nhận được thời gian thay đổi của tệp
  • Filegroup - Nhận nhóm tệp
  • FileInode - Nhận tệp Inode
  • FILEMTIME - Nhận thời gian sửa đổi tệp
  • FileOwner - Nhận chủ sở hữu tệp
  • FILEPERMS - Nhận quyền tệp
  • Tệp - Nhận kích thước tệp
  • FileType - Nhận loại tệp
  • Đàn - Khóa tệp tư vấn di động
  • fnmatch - Tên tệp phù hợp với một mẫu
  • Fopen - Mở tệp hoặc URL
  • FASSTHRU - Đầu ra tất cả dữ liệu còn lại trên con trỏ tệp
  • FPUTCSV - Dòng định dạng là CSV và ghi vào tệp con trỏ
  • fputs - bí danh của fwrite
  • FREAD-Tệp an toàn nhị phân đọc
  • fscanf - phân tích cú pháp đầu vào từ một tệp theo định dạng
  • FSEEK - Tìm kiếm trên một con trỏ tệp
  • FSTAT - Nhận thông tin về một tệp bằng con trỏ tệp mở
  • FSYNC-Đồng bộ hóa các thay đổi cho tệp (bao gồm cả dữ liệu meta)
  • FTELL - Trả về vị trí hiện tại của con trỏ đọc/ghi tệp
  • ftruncate - cắt một tệp thành một độ dài nhất định
  • FWRite-Viết tệp an toàn nhị phân
  • GLOB - Tìm tên đường dẫn khớp với một mẫu
  • IS_DIR - cho biết tên tệp có phải là thư mục không
  • is_executable - cho biết liệu tên tệp có thể thực thi được không
  • IS_FILE - cho biết tên tệp có phải là một tệp thông thường không
  • is_link - cho biết liệu tên tệp có phải là một liên kết tượng trưng
  • is_readable - cho biết liệu một tệp có tồn tại hay không và có thể đọc được không
  • IS_UPLOADED_FILE - cho biết liệu tệp có được tải lên qua bài đăng HTTP không
  • is_wrable - cho biết liệu tên tệp có thể ghi được không
  • IS_WRITABLE - Bí danh của is_writable
  • LCHGRP - Thay đổi quyền sở hữu nhóm của Symlink
  • LCHown - Thay đổi quyền sở hữu người dùng của Symlink
  • Liên kết - Tạo một liên kết cứng
  • LinkInfo - Nhận thông tin về một liên kết
  • LSTAT - Cung cấp thông tin về một tệp hoặc liên kết tượng trưng
  • MKDIR - Làm thư mục
  • Move_uploaded_file - Di chuyển một tệp được tải lên đến một vị trí mới
  • parse_ini_file - phân tích tệp cấu hình
  • Parse_ini_String - phân tích chuỗi cấu hình
  • PathInfo - Trả về thông tin về đường dẫn tệp
  • PCLOSE - Đóng con trỏ tệp quá trình
  • Popen - Mở con trỏ tệp quy trình
  • readfile - xuất ra một tệp
  • readlink - Trả về mục tiêu của một liên kết tượng trưng
  • RealPath_cache_get - Nhận các mục lưu trữ realpath
  • RealPath_cache_size - Nhận kích thước bộ nhớ cache realpath
  • RealPath - Trả về tên đường dẫn tuyệt đối chính thức
  • Đổi tên - Đổi tên một tệp hoặc thư mục
  • Tua lại - Tua lại vị trí của con trỏ tệp
  • RMDIR - Xóa thư mục
  • set_file_buffer - bí danh của stream_set_write_buffer
  • Stat - cung cấp thông tin về một tệp
  • Symlink - Tạo một liên kết tượng trưng
  • Tempnam - Tạo tệp có tên tệp duy nhất
  • TMPFILE - Tạo một tệp tạm thời
  • Touch - Đặt thời gian truy cập và thời gian sửa đổi của tệp
  • UMASK - Thay đổi UMASK hiện tại
  • Khóc - xóa một tệp

Cơ đốc giáo ¶

15 năm trước

I just learned that, to specify file names in a portable manner, you DON'T need 'DIRECTORY_SEPARATOR' - just use '/'. This really surprised and shocked me, as until now I typed about a zillion times 'DIRECTORY_SEPARATOR' to stay platform independent - unnecessary. Don't make the same mistake.

Drapeko.com

13 năm trước

You have an array of directories (straightforward list of directories):

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?

First of all the below function will help us.

/**
* This function converts real filesystem path to the string array representation.
*
* for example,
* '/home/drapeko/var/y            will be converted to    $result_array['home']['drapeko']['var']['y']
* '/home/drapeko/var/y/file.txt   will be converted to       $result_array['home']['drapeko']['var']['y']
*
* @param $path         realpath of the directory
* @return string        string array representation of the path
*/
function pathToArrayStr($path) {
    
// TODO constants/configs?
    
$res_path = str_replace(array(':/', ':\\', '/', '\\', DIRECTORY_SEPARATOR), '/', $path);
    
// if the first or last symbol is '/' delete it (e.g. for linux)
    
$res_path = preg_replace(array("/^\//", "/\/$/"), '', $res_path);
    
// create string
    
$res_path = '[\''.str_replace('/', '\'][\'', $res_path).'\']';

     return

$res_path;
}
?>

It simply converts the real path of the file to array string representation.

How can you use this function? I know it looks like a little confusing. But it's quite simple. Consider the example below:

$result = array();
$check = array();
foreach(
$array as $val) {
    
$str = pathToArrayStr($val, 'result');
     foreach(
$check as $ck) {
         if (
strpos($ck, $str) !== false) {
             continue
2;
         }
     }
    
$check[] = $str;
     eval(
'$result'.$str.' = array();');
}
print_r($result);
?>

Heh, how do you find it? This approach has helped me very much. I hope you will find it useful. :)

đường hầm tại gmail dot com

17 năm trước

I made this function to search and/or display files by extension or for a string occurance in the filename. Any comments or enhancements are welcome offcourse. I'll update this function soon.

usage: list_files([string], [string], [int 1 | 0], [int 1 | 0]);

You have an array of directories (straightforward list of directories): 0

You have an array of directories (straightforward list of directories): 1

You have an array of directories (straightforward list of directories): 2

You have an array of directories (straightforward list of directories): 3

Mitra tại Mitra Dot Biz ¶

19 năm trước

You have an array of directories (straightforward list of directories): 4

You have an array of directories (straightforward list of directories): 5

You have an array of directories (straightforward list of directories): 6

You have an array of directories (straightforward list of directories): 7

You have an array of directories (straightforward list of directories): 8

You have an array of directories (straightforward list of directories): 9

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:
0

You have an array of directories (straightforward list of directories): 3

Gregor Mosheh ¶

19 năm trước

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:
2

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:
3

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:
4

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:
5

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:
6

You have an array of directories (straightforward list of directories): 3

Gregor Mosheh ¶

19 năm trước

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:
8

     $array = array(
        
'/home/drapeko/var',
        
'/home/drapeko/var/y',
        
'/home/drapeko',
        
'/home',
        
'/var/libexec'
    
);
     );
?>

And you would like to transform this array to hierarchy of directories:
9

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
0

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
1

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
2

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
3

You have an array of directories (straightforward list of directories): 3

Gregor Mosheh ¶

19 năm trước

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
5

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
6

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
7

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
8

$array = array (
    
'home' => array (
        
'drapeko' => array (
            
'var' => array (
                
'y' => array()
             )
         )
     ),
    
'var' => array(
        
'libexec' => array()
     )
);
?>

How can you do it?
9

First of all the below function will help us. 0

First of all the below function will help us. 1

First of all the below function will help us. 2

First of all the below function will help us. 3

First of all the below function will help us. 4

You have an array of directories (straightforward list of directories): 3

Gregor Mosheh ¶

JDHURN tại Uberidx Dot Com ¶

First of all the below function will help us. 6

First of all the below function will help us. 7

First of all the below function will help us. 8

You have an array of directories (straightforward list of directories): 3

Tệp trong PHP là gì?

Một tập tin với. Tiện ích mở rộng tệp PHP là một tệp văn bản đơn giản chứa mã nguồn được viết trong PHP (đó là từ viết tắt đệ quy có nghĩa là ngôn ngữ lập trình PHP: Tiền xử lý siêu văn bản). PHP thường được sử dụng để phát triển các ứng dụng web được xử lý bởi công cụ PHP trên máy chủ web.a plain-text file that contains the source code written in the PHP (it's a recursive acronym meaning PHP: Hypertext Preprocessor) programming language. PHP is often used to develop web applications that are processed by a PHP engine on the web server.

PATH $ PATH trong PHP là gì?

Mô tả ¶ Dirname (Chuỗi $ Path, int $ level = 1): Chuỗi.Đưa ra một chuỗi chứa đường dẫn của tệp hoặc thư mục, hàm này sẽ trả về đường dẫn của thư mục cha được cấp từ thư mục hiện tại.string. Given a string containing the path of a file or directory, this function will return the parent directory's path that is levels up from the current directory.

Làm cách nào để tìm đường dẫn của một tệp trong PHP?

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ó bao nhiêu loại tệp trong PHP?

Hàm fileType () chấp nhận tên tệp dưới dạng tham số và trả về một trong bảy loại tệp thành công và sai về lỗi.Bảy giá trị trả về có thể của hàm filetype () là: Tệp: Tệp thông thường.seven file types on success and False on failure. The seven possible return values of the filetype() function are: file: regular file.