File manipulation functions in PHP (read-Write, properties, executable

Source: Internet
Author: User

if (is_executable ("test.txt"))//to judge a file
{
echo "File executable"; Output results
}
else//If the file is not executable
{
echo "File not executable"; Output information
}

//

Var_dump (Is_file ("Test.txt")). "        <br> "; To judge a file
Var_dump (Is_file ("C:/windows")). "       <br> "; To judge a file

//

$file = "Test.txt"; Definition file
$filestat =stat ($file); Return file information
Print_r (Array_slice ($filestat, 13)); Output results

//

$path =pathinfo ("test.txt"); Define Path
echo $path ["DirName"]. "         <br> "; Output array dirname
echo $path ["basename"]. "        <br> "; Output result Array basename
echo $path ["extension"]. "         <br> "; Output results Extension

//

$filename = "Test.txt"; Definition file
if (is_writable ($filename))//Determine if the file is writable
{
echo "File writable"; Output information
}
else//If the file is not writable
{
echo "File not writable"; Output information
}
/*
The output is similar to the following:
Files can be written
*/

$filename = "test.txt";           //definition file
If is_readable ($ filename))          //to determine if the file is readable by
{
  echo "File readable";           //output Information
}
else              //If the file is not readable
{
  echo "file is unreadable";          //output Information
}
/*
Output is similar to:
File readable
*/

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.