「PHP Programming/Files」の版間の差分

M
In short, when writing code to work with files, always assume the worst. Assume the file doesn't exist and you don't have permission to read/write to it. In most cases this means you have to tell the user that, in order for the script to work, he/she needs to adjust those file permissions so that PHP can create files and read/write to them but it also means that your script can adjust and perform an alternative operation.
 
There are two main ways of error checking. The first is by using the '[http://uk.php.net/manual/en/language.operators.errorcontrol.php @]' operator to suppress any errors when working with the file and then checking if the result is __false__'''false''' or not. The second method involves using more functions like [http://php.net/file_exists file_exists()], [http://php.net/is_readable is_readable()] and [http://php.net/is_writeable is_writeable()].
 
{{Code:Basic
匿名利用者