basename-returns the file name part of the path
dirname-returns the directory part of the path
Copy Code code as follows:
String basename (String $path [, String $suffix])
String DirName (String $path)
Example:
Copy Code code as follows:
<?php
$path = "/home/httpd/phpha.com/index.php";
Echo basename ($path);
Echo basename ($path, '. php ');
Echo basename ($path, '. xxx ');
echo dirname ($path);
?>
Copy Code code as follows:
Results:
index.php
Index
index.php
/home/httpd/phpha.com
Description: If the filename is ended with the correct suffix, this part will also be removed.
chgrp-change the group to which the file belongs
chown-change the owner of the file
chmod-Change File Mode
Copy Code code as follows:
BOOL Chmod (string $filename, int $mode)
Example:
Copy Code code as follows:
<?php
chmod ('/home/phpha.txt ', 0755);
?>
copy-Copy Files
if (copy (' index.php ', ' Index.php.bak ')) {
echo ' Copy success ';
}
?>
Index.php.bak files exist in the current directory
delete-See unlink or unset
unlink-Delete Files
Copy Code code as follows:
<?php
if (unlink (' Index.php.bak ')) {
Echo ' unlink success ';
}
?>
Removed the Index.php.bak
disk_free_space-returns the available space in the catalog
disk_total_space-returns the total disk size of a directory
Alias of Diskfreespace-disk_free_space
Copy Code code as follows:
<?php
Under Windows:
Echo Disk_free_space ("C:"), ' <br/> ';
Echo Disk_total_space ("C:");
?>
Copy Code code as follows:
Result: The number of bytes returned
17433419776
32218386432
fopen-open a file or URL
Fgets-reads a row from the file pointer
feof-the test file pointer to the end of the file
fread-read files (can be used securely in binary files)
fwrite-Write to file (safe for binary files)
fclose-closes an open file pointer
Copy Code code as follows:
<?php
$fp = fopen (' hello.txt ', ' R '); Open a file
$n = 1;
while (!feof ($fp)) {
Echo $n, '-', fgets ($fp), ' <br/> '; Read a row and output
$n + +;
}
Fclose ($FP); Close File
?>
Copy Code code as follows:
Output:
1-welcome to my blog:
2-http://www.jb51.net
Fgetc-reads characters from the file pointer
Fgetcsv-reads a line from the file pointer and resolves the CSV field
Fgetss-reads a row from the file pointer and filters out the HTML markup
fputcsv-the row into CSV and writes the file pointer
Alias of Fputs-fwrite
Copy Code code as follows:
<?php
$fp = fopen (' hello.txt ', ' R ');
while (false!== ($char = fgetc ($fp))) {
Echo $char, '-';
}
?>
Copy Code code as follows:
Output:
w-e-l-c-o-m-e--t-o--m-y--b-l-o-g-:---h-t-t-p-:-/-/-b-l-o-g-.-p-h-p-h-a-.-c-o-m-
file_exists-check whether a file or directory exists
Copy Code code as follows:
<?php
if (file_exists (' Hello.txt ')) {
Echo ' hello.txt exists ';
}else{
Echo ' hello.txt not exists ';
}
?>
[/code]
Output:
Hello.txt exists
[/code]
file_get_contents-reads the entire file into a string
File_put_contents-writes a string to a file
File-reads the entire file into an array
Copy Code code as follows:
<?php
if ($content = file_get_contents (' hello.txt ')) {
File_put_contents (' Hello.txt.bak ', $content);
}
?>
It's equivalent to a copy of Hello.txt.
<?php
if ($content = file (' hello.txt ')) {
Print_r ($content);
}
?>
Array form, each row is an array member
Array
(
[0] => Welcome to my blog:
[1] => http://www.jb51.net
)
Fileatime-last access time for files
Filectime-Gets the Inode modification time of the file
filegroup-the group that gets the file
Fileinode-get the inode of the file
filemtime-Get File modification time
Fileowner-gets the owner of the file
fileperms-permission to obtain files
filesize-Get File size
filetype-Get file type
Copy Code code as follows:
<?php
echo fileatime (' hello.txt ');
echo filectime (' hello.txt ');
echo filegroup (' hello.txt ');
echo filemtime (' hello.txt ');
echo fileowner (' hello.txt ');
Echo substr (sprintf ('%o ', fileperms (' Hello.txt ')),-4);
echo filesize (' hello.txt ');
echo filetype (' hello.txt ');
?>
Copy Code code as follows:
Output:
1353329003
1353329003
0
1353330002
0
0666
42
File
flock-Lightweight Consultation File lock
fnmatch-match filename with pattern
fflush-output The buffered content to a file
fpassthru-all remaining data at the output file pointer
fscanf-format input from a file
fseek-position in file pointer
fstat-access to file information through an open file pointer
ftell-returns the location of the file pointer read/write
ftruncate-the file to a given length
glob-find a file path that matches the pattern
is_dir-determine if a given file name is a directory
is_executable-to determine if a given file name is executable
is_file-to determine if a given file name is a normal file
is_link-determines whether a given file name is a symbolic connection
is_readable-to determine if a given file name is readable
is_uploaded_file-to determine if the file was uploaded via an HTTP POST
is_writable-to determine if a given filename is writable
Alias of Is_writeable-is_writable
Description: The above functions are used to determine whether a file or directory meets the corresponding conditions, return TRUE or false.
Lchgrp-changes group Ownership of Symlink
Lchown-changes user ownership of Symlink
link-establish a hard connection
LinkInfo -Get information for a connection
lstat-a file or symbolic connection
mkdir-new directory
move_uploaded_file-move uploaded files to a new location
parse_ini_file-resolve a configuration file
Pathinfo-returns information about the file path
pclose-closes the process file pointer
popen-open process file pointer
readfile-output a file
readlink-returns the target to which the symbolic connection is directed
realpath-returns the normalized absolute pathname
rename-Rename a file or directory
rewind-the location of the file pointer back
rmdir-Delete directory
set_file_buffer-stream_set_ Write_buffer alias
stat-give the file information
symlink-establish a symbolic connection
tempnam-create a file with a unique file name
tmpfile-Create a temporary file
touch-settings file Access and modify time
umask-change the current umask
clearstatcache-purge file state cache