Introduction: This is a detailed page for PHP to call remote URLs. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 329765 'rolling = 'no'>
1. Use file_get_contents to get the content in get mode.
Example:
$ Html = file_get_contents ($ URL );
2. Use fopen to open the URL and get the content
Example:
$ Fp = fopen ($ URL, 'R'); $ html = stream_get_meta_data ($ FP );
3. Use the file_get_contents function to obtain the URL in post mode.
$ DATA = array ('test' => 'hellword'); $ DATA = http_build_query ($ data ); $ opts = array ('http' => array ('method' => 'post', 'header' => "Content-Type: application/X-WWW-form-urlencoded \ r \ n ". "Content-Length :". strlen ($ data ). "\ r \ n", 'content' => $ data),); $ context = stream_context_create ($ opts); $ html = file_get_contents ($ URL, false, $ context );
4. Before using the curl library, make sure that curl extension is enabled.
$ CH = curl_init (); $ timeout = 5; curl_setopt ($ ch, curlopt_url, $ URL); curl_setopt ($ ch, success, 1); curl_setopt ($ ch, curlopt_connecttimeout, $ timeout); $ file_contents = curl_exec ($ ch); curl_close ($ ch); echo $ file_contents;
More articles on "four methods for PHP to call remote URLs"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/329765.html pageno: 12.