Php file reading operation function

Source: Internet
Author: User
Php file operations are very powerful, and you can easily read local files and remote files! 1. for details about how to use fread (), see the following php code: & amp; lt ;? Php?file=&quot=phpddt.txt & quot; $ fp = fopen ($ f

Php file operations are very powerful, and you can easily read local files and remote files!
1. use fread () to obtain
See the following php code:


 

Running result:
Php point-to-point (www.phpddt.com), follow php development, and provide professional php tutorials!
2. fseek (resource handle, int offset [, int whence]) to offset the pointer to the offset.
(Php.txt content is [Welcome to www.phpddt.com ])
After running the following php code:


 

Result:
To www.phpddt.com
The whence parameters are described as follows:
SEEK_SET-set the position to be equal to the offset byte.
SEEK_CUR-set the position to add offset to the current position.
SEEK_END-set the position to add offset to the end of the file. (Assign value)
If no whence is specified, the default value is SEEK_SET.
3. the ftell () function is used to obtain the offset of the pointer position.
The php demo code is as follows:


 


Running result:
8
4. the rewind () function moves the file pointer to the specified position.
5. the parse_ini_file () function parses the. ini file and easily parses multi-dimensional arrays.Let's take a look at the php Tutorial below!
First, save the phpddt. ini file. the file content is as follows:
[Web1]
Url = "www.phpddt.com"
Name = php point-to-point
[Web2]
Url = "www.baidu.com"
Name = baidu search
Compile the following php code:


 


The running result is as follows:
Array
(
[Web1] => Array
(
[Url] => www.phpddt.com
[Name] => php point-to-point
)

[Web2] => Array
(
[Url] => www.baidu.com
[Name] => Baidu search
)

)

 

 

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.