Home  >  Article  >  Backend Development  >  Using CURL to forge sources to grab pages or files in PHP_PHP Tutorial

Using CURL to forge sources to grab pages or files in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:29:38798browse

Copy code The code is as follows:

// Initialization
$curl = curl_init();
// To access URL
curl_setopt($curl, CURLOPT_URL, 'http://asen.me/');
// Set source
curl_setopt($curl, CURLOPT_REFERER, 'http://google.com/ ');
// Do not enter content directly
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Save the drop result in $result
$result = curl_exec($curl);
// Close
curl_close($curl);

Note, when using this method, make sure your PHP environment supports and has the CURL module enabled.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323396.htmlTechArticleCopy code The code is as follows: // Initialization $curl = curl_init(); // The URL to be visited curl_setopt($ curl, CURLOPT_URL, 'http://asen.me/'); // Set the source curl_setopt($curl, CURLOPT_RE...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn