Php functions for obtaining remote file content. _ PHP Tutorial

Source: Internet
Author: User
Php functions for obtaining remote file content ,. Php functions for obtaining remote file content, a simple php function code for obtaining remote file content, strong compatibility. You can easily obtain the content of a remote file by calling this php function,

A simple php function code for obtaining remote file content, which is highly compatible. You can use this function to obtain the content of a remote file. The code is as follows:

/*** Read remote content ** @ return string */function get_url_content ($ url) {if (function_exists ("curl_init") {$ ch = curl_init (); $ timeout = 30; curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout ); $ file_contents = curl_exec ($ ch); curl_close ($ ch);} else {$ is_auf = ini_get ('allow _ url_fopen ')? True: false; if ($ is_auf) {$ file_contents = file_get_contents ($ url) ;}return $ file_contents ;}

The above is the function code for php to obtain remote file content. I hope this article will help you to learn about php programming.

Secret, a simple php function code for obtaining remote file content, with strong compatibility. You can use this method to obtain the content of a remote file...

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.