This is a discussion on Filesystem Object in PHP within the PHP Programming forums, part of the Web Development category; While copying If the destination file already exists, it will be overwritten....
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| delete () is a dummy manual entry to satisfy those people who are looking for unlink() or unset() in the wrong place.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| unlink () deletes a file. Similar to the Unix C unlink() function As of PHP 5.0.0 unlink() can also be used with some URL wrappers. Example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| unset() destroys the specified variables. Note that in PHP 3, unset() will always return TRUE (actually, the integer value 1). In PHP 4, however, unset() is no longer a true function: it is now a statement. As such no value is returned, and attempting to take the value of unset() results in a parse error. unset() example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The behavior of unset() inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is unset() inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before unset() was called. PHP Code: Code: something something
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| If a static variable is unset() inside of a function, unset() destroys the variable only in the context of the rest of a function. Following calls will restore the previous value of a variable. PHP Code: Code: Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 23
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| disk_free_space() if u give a string containing a directory, this function will return the number of bytes available on the corresponding filesystem or disk partition. example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| disk_total_space() if we give a string containing a directory, this function will return the total number of bytes on the corresponding filesystem or disk partition. example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| file() function used to read entire file into an array. Each element of the array corresponds to a line in the file, with the newline still attached.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Here the example for file() function PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| file_get_contents() - Reads entire file into a string. Identical to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Hi, fgetc -- Gets character from file pointer.Returns a string containing a single character read from the file pointed to by handle. Returns FALSE on EOF. fgetc() example PHP Code:
__________________ Regards, Senraj.A |
| |||
| Hi, file_exists -- Checks whether a file or directory exists.Returns TRUE if the file or directory specified by filename exists; FALSE otherwise. file exists example: ------------------- PHP Code:
__________________ Regards, Senraj.A |
| |||
| feof() returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE. feof() example with an invalid file pointer PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| If a connection opened by fsockopen() wasn't closed by the server, feof() will wait until a timeout has been reached to return TRUE. The default timeout value is 60 seconds. You may use stream_set_timeout() to change this value. The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() If passed file pointer is not valid you may get an infinite loop, because EOF fails to return TRUE.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| When you use stat(), lstat(), or any of the other functions listed in the affected functions list (below), PHP caches the information those functions return in order to provide faster performance. However, in certain cases, you may want to clear the cached information. For instance, if the same file is being checked multiple times within a single script, and that file is in danger of being removed or changed during that script's operation, you may elect to clear the status cache. In these cases, you can use the clearstatcache() function to clear the information that PHP caches about a file.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| And this function caches information about specific filenames, so you only need to call clearstatcache() if you are performing multiple operations on the same filename and require the information about that particular file to not be cached.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| flock() operates on handle which must be an open file pointer. operation is one of the following values:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| flock() allows you to perform a simple reader/writer model which can be used on virtually every platform (including most Unix derivatives and even Windows). The optional third argument is set to TRUE if the lock would block (EWOULDBLOCK errno condition). The lock is released also by fclose() (which is also called automatically when script finished).
__________________ With, J. Jeyaseelan Everything Possible |