added code to the original curl
curl_setopt($ch, CURLOPT_INTERFACE, "ppp0");
but it"s strange that you can see the result of calling
when you run the command php test.php on the server, but remote access to this address, such as http:// domain name / test.php
, can"t be opened all the time. What"s the reason for this?
the code is as follows
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.baidu.com/");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
curl_setopt($ch, CURLOPT_ENCODING, "gzip" );
curl_setopt($ch, CURLOPT_INTERFACE, "ppp0");
$html = curl_exec($ch);
curl_close($ch);
var_dump($html);
exit;