FAQs about file operations during PHP dynamic website creation _ PHP Tutorial

Source: Internet
Author: User
Tags php dynamic website
FAQs about file operations during PHP dynamic website creation. PHP supports operations on various types of databases, as well as file operations. many of my friends are still operating on files:

PHP supports operations on various types of databases, and also provides rich operation methods for file operations, many of my friends are still operating on files, but sometimes there are still many puzzles and doubts when operating on files, the following are some of the file operations problems I encountered during my daily writing and my friends encountered on the altar.

Q: How to create a file?

A:

1. use fopen (name of the file to be created, parameter). optional values: w, w, a, and.

2. use exec (echo ''> file name to be created). In this way, you can use the linux command touch to create this file.

Q: Why cannot I create a file?

A:

1. if you use fopen to create a file, is the parameter used correctly?

2. for system permission questions, please ask your WEBMASTER if your FTP directory has write permission

3. for FTP permissions, make sure that you have the write permission in the directory where the file to be written in your php file is located, that is, the other group must have the write permission after your FTP software logs in,
If you do not have the permission, modify the permission and try again.

Q: How do I read files into an array?

A: use the file function.

Q: How can I read all files?

A:
 
1. use fread ($ fp );

2. if your PHP version is> = 4.3.0, you can use file_get_contents ();

Q: How can I determine whether a file exists?

A: use file_exists ();

Q: Why not use fopen () for determination?

A: The reason is that the data returned by fopen sometimes leads us to incorrect judgment due to permission issues.

Q: Why does an error occur when I read a web page?

A:

1. it may be your passing Parameter error. when reading the web page, you can only read the page in r mode.

2. make sure that the WEB page you want to read can be accessed

Q: How can I obtain the relevant attributes of a file?

A: PHP provides a set of methods to obtain file attributes, such as filemtime (), fileowner (), filegroup (), filectime (), fileatime ()... for more information, see the manual.

Q: Can I locate the file "cursor" like C after opening the file in PHP?

A: Yes. use fseek ();

Q: What should I do if I do not allow other people to access the file when accessing the file?

A:

1. you can use other programs to restrict access to file pages.

PHP supports operations on various types of databases, and also has rich operation methods for file operations. many of my friends are still operating on files...

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.