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.元