$filename = '/path/to/foo.txt ';
if (file_exists ($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
Copy CodeIf the file is present, the
In most cases, you can use test commands to test the conditions. For example, you can compare strings, determine whether a file exists, and whether the file is readable. The following article describes how to use BashShell to check whether a file
The following is an example code that checks whether a file exists:
Copy CodeThe code is as follows:
$filename = '/path/to/foo.txt ';
if (file_exists ($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist"
1, Case:
Copy CodeThe code is as follows:
$file = ' jb51.net.php ';
if (is_readable ($file) = = False) {
Die (' file does not exist or cannot be read ');
} else {
echo ' presence ';
}
?>
The is_readable () function determines whether the
How can I check the data from an html post to a php file and then check the data in the PHP file? if there is a data error, a prompt is displayed in the html to re-enter the data? For example, if a new user of a website is registered and the user
fopen () method
The simplest way is to use fopen (), to see if the file can be opened, can hit the file of course exists.
The fopen () function opens the file or URL. If the open fails, the function returns FALSE.
Syntax: fopen
Php checks whether an uploaded file exists or has the same name. check whether there is an uploaded file functionsearchFile ($ path, $ file) {$ file_arrayarray () in the directory of the uploaded file (); array of file names $ folder_arrayarray ();
This article gives you the content is about how to check the existence of the remote file in PHP (pure code), there is a certain reference value, the need for a friend can refer to, I hope you have some help.
Check if the remote file exists
Php checks whether an uploaded file exists or has the same name. check whether there is an uploaded file functionsearchFile ($ path, $ file) {$ file_arrayarray () in the directory of the uploaded file (); store the file name array $
: This article mainly introduces php programming notes. if you are interested in PHP tutorials, please refer to them. Three methods for php to obtain POST data
Php image watermarking source code
Php + ajax + json is the simplest example.
Php Chinese
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.