Files A file is a sequence of bytes

Files A file is a sequence of bytes stored persistently on a physical medium like a hard disk. Each file is uniquely identified by its absolute path. For example, C:temptextfile.txt on Windows platforms or /private/user/textfile on UNIX platforms. On Windows, both the forward slash (/) and the backslash () can be used in file paths, whereas other operating systems use only the forward slash. As a good programming practice, you should define a global variable fileSeparator and use it for creating paths in your PHP programs. This is an extreme scenario, but, in some operating systems the forward slash (/) can be part of the filename. Most PHP applications follow these steps to read from or write to a file: . Open file . Read from and write to file . Close file Opening Files The fopen() function can be used to open any file in the server’s file system. It can also be used to open files via HTTP or FTP on the Internet. Here we will only look at how this function can be used to open files in the server’s file system: int fopen(string filename, string mode [, string use_include_path]) The argument filename can be the name of the file, or its absolute path. If filename is the name of the file, then it is assumed that the file is in the current working directory. The second argument indicates whether the file is to be opened for reading, writing, or appending. It can have one of the following possible values: Value Description R Open the file for reading only. r+ Open the file for reading and writing. W Open the file for writing only and truncate the file to zero length. All the contents of the file will be lost. If the file does not exist, PHP will try to create it. w+ Open the file for reading and writing. Truncate the file to zero length. If the file does not exist, PHP will try to create it. A Open a file for appending data. Data will be written at the end of an existing file. If the file does not exist, then PHP will try to create it. a+ Open a file for appending and reading data. Data will be written at the end of an existing file. If the file does not exist, then PHP will try to create it. B This flag must be used to read/write binary files on operating systems such as Windows that handle such files differently. The third argument specifies whether PHP should search for files in the include_path too. The include_path can be set in the php.ini configuration file. The fopen() function returns a file handle if successful, or false on failure. The file handle is used Page 237
Note: If you are looking for good and high quality web space to host and run your java application check Vision java hosting services

Comments are closed.