Phpfilesystem file system function usage
- $ Path = "/home/httpd/phpha.com/index.php ";
- Echo basename ($ path );
- Echo basename ($ path, '. php ');
- Echo basename ($ path, '. xxx ');
- Echo dirname ($ path );
- ?>
- // Result:
- Index. php
- Index
- Index. php
- /Home/httpd/phpha.com
Note: If the file name ends with a correct suffix file, this part will be removed. Chgrp-change the group to which the file belongs chown-change the file owner chmod-change the file mode bool chmod (string $ filename, int $ mode) Example 2:
- Chmod ('/home/phpha.txt', 0755 );
- ?>
-
Copy-copy an object
- If (copy ('index. php', 'index. php. bak ')){
- Echo 'copy success ';
- }
- ?>
- // The index. php. bak file is saved in the current directory.
-
Delete-see unlink or unset Unlink-delete file Example 3:
- If (unlink ('index. php. bak ')){
- Echo 'unlink success ';
- }
- ?>
- // Index. php. bak deleted
-
Disk_free_space-return the available space disk_total_space in the directory-return the alias of diskfreespace-disk_free_space of the total disk size in a directory Example 4:
- // In Windows:
- Echo disk_free_space ("C :"),'
';
- Echo disk_total_space ("C :");
- ?>
-
// Result: the returned number of bytes is 1743341977632218386432 fopen-open the file or URLfgets-read a row of feof from the file pointer-test whether the file pointer has reached the end of the file fread-read the file (which can be safely used for binary files) fwrite-write a file (which can be safely used for binary files) fclose-close an opened file pointer Example 5:
- $ Fp = fopen('hello.txt ', 'r'); // open a file
- $ N = 1;
- While (! Feof ($ fp )){
- Echo $ n, '-', fgets ($ fp ),'
'; // Read and output a row
- $ N ++;
- }
- Fclose ($ fp); // close the file
- ?>
-
// Output: 1-Welcome to my blog: 2-http://bbs.it-home.orgfgetc-read character fgetcsv from file pointer-read a line from file pointer and parse CSV field fgetss-read a line from file pointer and filter out HTML tag fputcsv-format row is CSV and writes the file pointer fputs-fwrite alias
- $ Fp = fopen('hello.txt ', 'r ');
- While (false! ==( $ Char = fgetc ($ fp ))){
- Echo $ char ,'-';
- }
- ?>
- // Output:
- W-e-l-c-o-m-e--t-o--m-y-B-l-o-g -: ---h-t-p-:-/-B-l-o-g -. -p-h--. -c-o-m-
-
12. Next page |