Home  >  Article  >  Backend Development  >  PHP file operation_PHP tutorial

PHP file operation_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:50:46878browse

if(!is_dir('txt'))//Determine whether txt is a folder directory
{
mkdir('txt');//Create a folder directory named txt
$open=fopen('txt/in.txt',"w+");//Open the file for reading and writing
If(is_writable('txt/in.txt'))//If this file is in writable mode
           {
If(fwrite($open,"Today is a beautiful day, you must be happy! "- -"")>0)//Write content
           fclose($open);//Close the file
echo "<script>alert('Writing successful');</script>";//Output success prompt
}
}
else
          {
If(is_file('txt/in.txt'))//Determine whether the in.txt file exists in the directory
                {
If(is_readable('txt/in.txt'))//Determine whether the file is readable
                                                               {
                                      echo file_get_contents('txt/in.txt');//Output text information
                        unlink('txt/in.txt');//Delete file in.txt
                                                                                                                                                                                                                  rmdir('txt');//Delete directory
                 }
            }
}
?>

Excerpted from ms.元

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478239.htmlTechArticle?php if(!is_dir(txt))//Judge whether txt is a folder directory { mkdir(txt) ;//Create a folder directory named txt $open=fopen(txt/in.txt,w+);//Open the file in read and write mode if(is_writable...
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