php打开就执行url,php执行URL解析
方法一:
$url="http://www.baidu.com";
file_get_contents($url);
方法二:
// CURL 方法
$url="http://www.baidu.com";
$ch = curl_init( );
curl_setopt( $ch,CURLOPT_URL,$url );
curl_setopt( $ch,CURLOPT_HEADER,0 );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER,1 );
$ret= curl_exec( $ch );
curl_close( $ch );
echo $ret;
方法三:
$url="http://www.baidu.com";
$fp=fopen($url,"r");
$response = '';
while($row = fgets($fp)) {
$response.= trim($row)."\n";
}
注意:如果ping的通但是無法調(diào)用遠程url,試試wget
Resolving www.xxx.com... 114.xxx.xxx.xxx
Connecting to www.xxx.com|114.xxx.xxx.xxx|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
10:58:22 ERROR 403: Forbidden.
這樣就不可以!
總結(jié)
以上是生活随笔為你收集整理的php打开就执行url,php执行URL解析的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dhcp 续约review报文_Linu
- 下一篇: php json传输被过滤,php-t