File_get_contents only reads part of the webpage-PHP source code

Source: Internet
Author: User
File_get_contents only reads part of the webpage content. In fact, this is the simplest and most primitive method for collecting articles. File_get_contents only reads part of the webpage content. In fact, this is the simplest and most primitive method for collecting articles.

Script ec (2); script

In the php tutorial

The file_get_contents function can open local files or read remote files.

Usage

File_get_contents ($ url );

Let's take a look at the example of file_get_contents collecting remote website content.

The Code is as follows:

$ Url = http://www.111cn.net

$ Content = file_get_contents ($ url );

If ($ content)

{

$ Array = explode ('', $ Content); print_r ($ array); </p>

}

Else

{

Echo 'collection not successful ';

}

// If the output is successful

Array (

0 => webpage creation tutorial-webpage design tutorial-professional Webpage Design and webpage creation tutorials

)

All right.

You can use functions such as fsockopen and fopen (allow_url_open needs to be set) to read remote server content.

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.