Php file operation functions (read/write, attributes, executable-PHP source code)

Source: Internet
Author: User
Ec(210000if(is_executable("test.txt & quot;) & nbsp; determine the file {& nbsp; echo & quot; executable file & quot; & nbsp; & nbsp; script ec (2); script

If (is_executable ("test.txt") // checks the file
{
Echo "file executable"; // output result
}
Else // if the file is not executable
{
Echo "file not executable"; // output information
}

//

Var_dump (is_file ("test.txt "))."
"; // Determine the file
Var_dump (is_file ("c:/windows "))."
"; // Determine the file

//

$ File = "test.txt"; // definition file
$ Filestat = stat ($ file); // returns the file information.
Print_r (array_slice ($ filestat, 13); // output the result

//

$ Path = pathinfo ("test.txt"); // defines path
Echo $ path ["dirname"]."
"; // Output array dirname
Echo $ path ["basename"]."
"; // Output result array basename
Echo $ path ["extension"]."
"; // Output result extension

//

$ Filename = "test.txt"; // definition file
If (is_writable ($ filename) // determines whether the file can be written.
{
Echo "file writable"; // output information
}
Else // if the file cannot be written
{
Echo "file not writable"; // output information
}
/*
The output result is similar:
File writable
*/

$ Filename = "test.txt"; // definition file
If (is_readable ($ filename) // checks whether the object is readable.
{
Echo "file readable"; // output information
}
Else // if the file is not readable
{
Echo "file unreadable"; // output information
}
/*
The output result is similar:
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.