From 2395b71a42e982267e40efb3048f6b412afbba92 Mon Sep 17 00:00:00 2001 From: Egon Schmid Date: Tue, 15 Aug 2000 21:19:54 +0000 Subject: [PATCH] A lot of cosmetic changes. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@30332 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/filesystem.xml | 311 +++++++++++++++++++-------------------- 1 file changed, 154 insertions(+), 157 deletions(-) diff --git a/functions/filesystem.xml b/functions/filesystem.xml index 7b43e6f85e..d5bcdf13a9 100644 --- a/functions/filesystem.xml +++ b/functions/filesystem.xml @@ -6,7 +6,7 @@ basename - Return filename component of path + Returns filename component of path @@ -32,7 +32,7 @@ <function>basename</function> example $path = "/home/httpd/html/index.php3"; -$file = basename($path); // $file is set to "index.php3" +$file = basename ($path); // $file is set to "index.php3" @@ -45,7 +45,7 @@ $file = basename($path); // $file is set to "index.php3" chgrp - Change file group + Changes file group Description @@ -58,9 +58,10 @@ $file = basename($path); // $file is set to "index.php3" Attempts to change the group of the file - filename to group. Only the - superuser may change the group of a file arbitrarily; other users may change - the group of a file to any group of which that user is a member. + filename to + group. Only the superuser may change the + group of a file arbitrarily; other users may change the group of + a file to any group of which that user is a member. Returns true on success; otherwise returns false. @@ -71,7 +72,7 @@ $file = basename($path); // $file is set to "index.php3" - This function does not work on Windows systems + This function does not work on Windows systems @@ -80,7 +81,7 @@ $file = basename($path); // $file is set to "index.php3" chmod - Change file mode + Changes file mode Description @@ -103,8 +104,8 @@ $file = basename($path); // $file is set to "index.php3" you need to prefix mode with a zero (0): -chmod( "/somedir/somefile", 755 ); // decimal; probably incorrect -chmod( "/somedir/somefile", 0755 ); // octal; correct value of mode +chmod ("/somedir/somefile", 755); // decimal; probably incorrect +chmod ("/somedir/somefile", 0755); // octal; correct value of mode @@ -117,7 +118,7 @@ chmod( "/somedir/somefile", 0755 ); // octal; correct value of mode - This function does not work on Windows systems + This function does not work on Windows systems @@ -126,7 +127,7 @@ chmod( "/somedir/somefile", 0755 ); // octal; correct value of mode chown - change file owner + Changes file owner Description @@ -159,7 +160,7 @@ chmod( "/somedir/somefile", 0755 ); // octal; correct value of mode clearstatcache - Clear file stat cache + Clears file stat cache Description @@ -208,7 +209,7 @@ chmod( "/somedir/somefile", 0755 ); // octal; correct value of mode copy - Copy file + Copies file Description @@ -223,10 +224,10 @@ chmod( "/somedir/somefile", 0755 ); // octal; correct value of mode Makes a copy of a file. Returns true if the copy succeeded, false otherwise. - <function>copy</function> example + <function>Copy</function> example -if ( !copy($file, $file.'.bak') ) { - print("failed to copy $file...<br>\n"); +if (!copy($file, $file.'.bak')) { + print ("failed to copy $file...<br>\n"); } @@ -250,13 +251,14 @@ if ( !copy($file, $file.'.bak') ) { string file - - This is a dummy manual entry to satisfy those people who are - looking for unlink or - unset in the wrong place. - - See also: unlink to delete files, - unset to delete variables. + + This is a dummy manual entry to satisfy those people who are + looking for unlink or + unset in the wrong place. + + + See also: unlink to delete files, + unset to delete variables. @@ -264,7 +266,7 @@ if ( !copy($file, $file.'.bak') ) { dirname - Return directory name component of path + Returns directory name component of path Description @@ -284,10 +286,10 @@ if ( !copy($file, $file.'.bak') ) { (/). - <function>dirname</function> example + <function>Dirname</function> example $path = "/etc/passwd"; -$file = dirname($path); // $file is set to "/etc" +$file = dirname ($path); // $file is set to "/etc" @@ -300,7 +302,7 @@ $file = dirname($path); // $file is set to "/etc" diskfreespace - Return available space in directory + Returns available space in directory Description @@ -330,7 +332,7 @@ $df = diskfreespace("/"); // $df contains the number of bytes fclose - Close an open file pointer + Closes an open file pointer Description @@ -357,7 +359,7 @@ $df = diskfreespace("/"); // $df contains the number of bytes feof - Test for end-of-file on a file pointer + Tests for end-of-file on a file pointer Description @@ -382,7 +384,7 @@ $df = diskfreespace("/"); // $df contains the number of bytes fgetc - Get character from file pointer + Gets character from file pointer Description @@ -413,7 +415,7 @@ $df = diskfreespace("/"); // $df contains the number of bytes fgetcsv - Get line from file pointer and parse for CSV fields + Gets line from file pointer and parse for CSV fields @@ -431,22 +433,24 @@ $df = diskfreespace("/"); // $df contains the number of bytes - Similar to fgets() except that fgetcsv() parses the line it reads - for fields in CSV format and returns an array containing the - fields read. The field delimiter is a comma, unless you specifiy - another delimiter with the optional third parameter. + Similar to fgets except that + fgetcsv parses the line it reads for fields + in CSV format and returns an array containing + the fields read. The field delimiter is a comma, unless you + specifiy another delimiter with the optional third parameter. - fp must be a valid file pointer to a file successfully opened by - fopen, popen, or - fsockopen + Fp must be a valid file pointer to a file + successfully opened by fopen, + popen, or fsockopen - length must be greater than the longest line to be found in the + Length must be greater than the longest line to be found in the CSV file (allowing for trailing line-end characters). - fgetcsv() returns false on error, including end of file. + Fgetcsv returns false on error, including + end of file. NB A blank line in a CSV file will be returned as an array @@ -478,7 +482,7 @@ fclose ($fp); fgets - Get line from file pointer + Gets line from file pointer Description @@ -517,7 +521,7 @@ fclose ($fp); Reading a file line by line $fd = fopen ("/tmp/inputfile.txt", "r"); -while (!feof($fd)) { +while (!feof ($fd)) { $buffer = fgets($fd, 4096); echo $buffer; } @@ -537,7 +541,7 @@ fclose ($fd); fgetss - Get line from file pointer and strip HTML tags + Gets line from file pointer and strip HTML tags @@ -577,11 +581,10 @@ fclose ($fd); - file - read entire file into an array + Reads entire file into an array Description @@ -594,37 +597,33 @@ fclose ($fd); - Identical to readfile, except that file returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached. - You can use the optional second parameter and set it to "1", if you want to search for the file in the include_path, too. - - + <?php // get a web page into an array and print it out -$fcontents = file( 'http://www.php.net' ); -while ( list( $line_num, $line ) = each( $fcontents ) ) { - echo "<b>Line $line_num:</b> " . htmlspecialchars( $line ) . "<br>\n"; +$fcontents = file ('http://www.php.net'); +while (list ($line_num, $line) = each ($fcontents)) { + echo "<b>Line $line_num:</b> " . htmlspecialchars ($line) . "<br>\n"; } // get a web page into a string -$fcontents = join( '', file( 'http://www.php.net' ) ); +$fcontents = join ('', file ('http://www.php.net')); ?> - See also readfile, fopen, and popen. @@ -636,7 +635,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); file_exists - Check whether a file exists + Checks whether a file exists Description @@ -646,23 +645,19 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); string filename - Returns true if the file specified by filename exists; false otherwise. - file_exists will not work on remote files; the file to be examined must be accessible via the server's filesystem. - The results of this function are cached. See clearstatcache for more details. - @@ -670,7 +665,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); fileatime - Get last access time of file + Gets last access time of file Description @@ -680,17 +675,14 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); string filename - Returns the time the file was last accessed, or false in case of an error. The time is returned as a Unix timestamp. - The results of this function are cached. See clearstatcache for more details. - Note: The atime of a file is supposed to change whenever the data blocks of a file are being read. This can be @@ -701,15 +693,13 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); news spools are a common example. On such filesystems this function will be useless. - - filectime - Get inode change time of file + Gets inode change time of file Description @@ -731,9 +721,9 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); changed, when it's Inode data is changed, that is, when the permissions, the owner, the group or other metadata from the Inode is written to. See also - filemtime() (this is what you want to use + filemtime (this is what you want to use when you want to create "Last Modified" footers on web pages) and - fileatime(). + fileatime. Note: In some Unix texts the ctime of a file is being referred to as the creation time of the file. This is wrong. @@ -746,7 +736,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); filegroup - Get file group + Gets file group Description @@ -776,7 +766,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); fileinode - Get file inode + Gets file inode Description @@ -804,7 +794,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); filemtime - Get file modification time + Gets file modification time Description @@ -825,7 +815,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); Note: This function returns the time when the data blocks of a file were being written to, that is, the time when the content of the file was changed. Use - date() on the result of this function + date on the result of this function to get a printable modification date for use in page footers. @@ -834,7 +824,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); fileowner - Get file owner + Gets file owner Description @@ -864,7 +854,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); fileperms - Get file permissions + Gets file permissions Description @@ -887,7 +877,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); filesize - Get file size + Gets file size Description @@ -910,7 +900,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); filetype - Get file type + Gets file type Description @@ -967,37 +957,42 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); To acquire a shared lock (reader), set - operation to LOCK_SH (set to 1 prior to PHP 4.0.1). + operation to LOCK_SH (set to 1 prior to + PHP 4.0.1). To acquire an exclusive lock (writer), set - operation to LOCK_EX (set to 2 prior to PHP 4.0.1). + operation to LOCK_EX (set to 2 prior to + PHP 4.0.1). To release a lock (shared or exclusive), set - operation to LOCK_UN (set to 3 prior to PHP 4.0.1). + operation to LOCK_UN (set to 3 prior to + PHP 4.0.1). If you don't want flock to block while - locking, add LOCK_NB (4 prior to PHP 4.0.1) to operation. + locking, add LOCK_NB (4 prior to PHP 4.0.1) to + operation. - flock allows you to perform a simple + Flock allows you to perform a simple reader/writer model which can be used on virtually every platform - (including most Unices and even Windows). The optional 3rd argument - is set to true if the lock would block (EWOULDBLOCK errno condition) + (including most Unices and even Windows). The optional 3rd + argument is set to true if the lock would block (EWOULDBLOCK + errno condition) - flock returns true on success and false on + Flock returns true on success and false on error (e.g. when a lock could not be acquired). @@ -1006,7 +1001,7 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); fopen - Open file or URL + Opens file or URL Description @@ -1111,11 +1106,11 @@ $fcontents = join( '', file( 'http://www.php.net' ) ); - fopen() example + <function>Fopen</function> example -$fp = fopen("/home/rasmus/file.txt", "r"); -$fp = fopen("http://www.php.net/", "r"); -$fp = fopen("ftp://user:password@example.com/", "w"); +$fp = fopen ("/home/rasmus/file.txt", "r"); +$fp = fopen ("http://www.php.net/", "r"); +$fp = fopen ("ftp://user:password@example.com/", "w"); @@ -1130,7 +1125,7 @@ $fp = fopen("ftp://user:password@example.com/", "w"); used in the path to the file, or use forward slashes. -$fp = fopen("c:\\data\\info.txt", "r"); +$fp = fopen ("c:\\data\\info.txt", "r"); @@ -1187,7 +1182,7 @@ $fp = fopen("c:\\data\\info.txt", "r"); fputs - Write to a file pointer + Writes to a file pointer Description @@ -1204,7 +1199,7 @@ $fp = fopen("c:\\data\\info.txt", "r"); - fputs is an alias to + Fputs is an alias to fwrite, and is identical in every way. Note that the length parameter is optional and if not specified the entire string will be written. @@ -1227,7 +1222,7 @@ $fp = fopen("c:\\data\\info.txt", "r"); - fread reads up to + Fread reads up to length bytes from the file pointer referenced by fp. Reading stops when length bytes have been read or EOF is @@ -1248,8 +1243,8 @@ fclose ($fd); See also fwrite, fopen, fsockopen, popen, fgets, fgetss, - fscanf, - file, and fpassthru. + fscanf, file, and + fpassthru. @@ -1272,40 +1267,40 @@ fclose ($fd); - The function fscanf is similar to - sscanf, but it takes its input from a file - associated with handle and interprets the input - according to the specified format. If only two - parameters were passed to this function, the values parsed will be - returned as an array. Otherwise, if optional parameters are passed, the - function will return the number of assigned values. The optional - parameters must be passed by reference. - - <function>Fscanf</function> Example - -$fp = fopen("users.txt","r"); -while ($userinfo = fscanf($fp,"%s\t%s\t%s\n")) { - list($name, $profession, $countrycode) = $userinfo; - //... do something with the values + The function fscanf is similar to + sscanf, but it takes its input from a file + associated with handle and interprets the + input according to the specified + format. If only two parameters were passed + to this function, the values parsed will be returned as an array. + Otherwise, if optional parameters are passed, the function will + return the number of assigned values. The optional parameters + must be passed by reference. + + <function>Fscanf</function> Example + +$fp = fopen ("users.txt","r"); +while ($userinfo = fscanf ($fp, "%s\t%s\t%s\n")) { + list ($name, $profession, $countrycode) = $userinfo; + //... do something with the values } fclose($fp); - - - - users.txt - -javier argonaut pe -hiroshi sculptor jp -robert slacker us -luigi florist it - - + + + + users.txt + +javier argonaut pe +hiroshi sculptor jp +robert slacker us +luigi florist it + + - See also fread, - fgets, fgetss, - sscanf, printf, - and sprintf. + See also fread, fgets, + fgetss, sscanf, + printf, and sprintf. @@ -1313,7 +1308,7 @@ luigi florist it fseek - Seek on a file pointer + Seeks on a file pointer Description @@ -1322,7 +1317,9 @@ luigi florist it int fseek int fp int offset - int whence + int + whence + @@ -1354,10 +1351,10 @@ luigi florist it formats. - + The whence argument was added after PHP 4.0 RC1. - - + + See also ftell and rewind. @@ -1369,7 +1366,7 @@ luigi florist it fstat - Get information about a file using an open file pointer. + Gets information about a file using an open file pointer @@ -1415,7 +1412,7 @@ luigi florist it ftell - Tell file pointer read/write position + Tells file pointer read/write position Description @@ -1448,7 +1445,7 @@ luigi florist it ftruncate - Truncate a file to a given length. + Truncates a file to a given length. @@ -1762,7 +1759,7 @@ luigi florist it linkinfo - Get information about a link + Gets information about a link Description @@ -1795,7 +1792,7 @@ luigi florist it mkdir - Make directory + Makes directory Description @@ -1830,7 +1827,7 @@ mkdir ("/path/to/my/dir", 0700); pclose - Close process file pointer + Closes process file pointer Description @@ -1861,7 +1858,7 @@ mkdir ("/path/to/my/dir", 0700); popen - Open process file pointer + Opens process file pointer Description @@ -1903,7 +1900,7 @@ $fp = popen ("/bin/ls", "r"); readfile - Output a file + Outputs a file Description @@ -1964,7 +1961,7 @@ $fp = popen ("/bin/ls", "r"); readlink - Return the target of a symbolic link + Returns the target of a symbolic link Description @@ -1995,7 +1992,7 @@ $fp = popen ("/bin/ls", "r"); rename - Rename a file + Renames a file Description @@ -2046,7 +2043,7 @@ $fp = popen ("/bin/ls", "r"); rmdir - Remove directory + Removes directory Description @@ -2073,7 +2070,7 @@ $fp = popen ("/bin/ls", "r"); stat - Give information about a file + Gives information about a file Description @@ -2116,7 +2113,7 @@ $fp = popen ("/bin/ls", "r"); lstat - Give information about a file or symbolic link + Gives information about a file or symbolic link @@ -2164,7 +2161,7 @@ $fp = popen ("/bin/ls", "r"); realpath - Return canonicalized absolute pathname + Returns canonicalized absolute pathname Description @@ -2181,12 +2178,11 @@ $fp = popen ("/bin/ls", "r"); absolute pathname. The resulting path will have no symbolic link, '/./' or '/../' components. - <function>realpath</function> example -$real_path = realpath("../../index.php"); +$real_path = realpath ("../../index.php"); @@ -2196,7 +2192,7 @@ $real_path = realpath("../../index.php"); symlink - Create a symbolic link + Creates a symbolic link Description @@ -2219,7 +2215,7 @@ $real_path = realpath("../../index.php"); - This function does not work on Windows systems + This function does not work on Windows systems. @@ -2228,7 +2224,7 @@ $real_path = realpath("../../index.php"); tempnam - create unique file name + Creates unique file name Description @@ -2269,7 +2265,7 @@ $tmpfname = tempnam ("/tmp", "FOO"); touch - Set modification time of file + Sets modification time of file Description @@ -2295,12 +2291,13 @@ $tmpfname = tempnam ("/tmp", "FOO"); Returns true on success and false otherwise. - <function>touch</function> example + <function>Touch</function> example -if ( touch($FileName) ) { - print "$FileName modification time has been changed to todays date and time"; +if (touch ($FileName)) { + print "$FileName modification time has been + changed to todays date and time"; } else { - print "Sorry Could Not change modification time of $FileName"; + print "Sorry Could Not change modification time of $FileName"; } @@ -2336,7 +2333,7 @@ if ( touch($FileName) ) { unlink - Delete a file + Deletes a file Description @@ -2358,7 +2355,7 @@ if ( touch($FileName) ) { - This function may not work on Windows systems. + This function may not work on Windows systems.