Home >Backend Development >PHP Tutorial >PHP determines whether a file or directory (folder) exists_PHP tutorial

PHP determines whether a file or directory (folder) exists_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:57:262543browse

php determines whether a file or directory (folder) exists

The php library has its own function to determine whether a file or directory exists. file_exists determines whether a file exists, and is_dir determines a directory ( folder) exists. Specific examples are as follows:

$file='index.php';
$dir='www.phpernote.com/wwwroot/';
if(file_exists($dir.$file)){
	echo '文件'.$file.'存在';
}else{
	echo '文件'.$file.'不存在';
}
if(is_dir($dir)){
    echo '目录'.$dir.'存在';
}else{
    echo '目录'.$dir.'不存在';
}

Articles you may be interested in

  • How to clear (delete) the files in the specified directory without deleting the directory folder with php
  • php get all the files in the directory A program that saves the results to an array
  • How to determine whether a remote file exists in PHP
  • Detailed explanation of linux chmod (file or folder permission setting) command parameters and usage
  • PHP determines whether functions, classes, and class methods exist
  • Linux delete files and folders command rm command details
  • The safest and most realistic solution for PHP to determine the type of uploaded files
  • php method to determine whether a string is all in English, pure Chinese, or a combination of Chinese and English

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/982049.htmlTechArticlephp determines whether a file or directory (folder) exists. The php library has its own function to determine whether a file or directory exists. , file_exists determines whether the file exists, is_dir determines whether the directory (folder) is...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn