我使用這個代碼的網頁的打印內容(源代碼)工作:打印內容不爲google.com
<?php
$url='http://cloob.com';
$ch=curl_init();
$timeout=5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Get URL content
$lines_string=curl_exec($ch);
// close handle to release resources
curl_close($ch);
var_dump(htmlspecialchars($lines_string));
//echo htmlentities($lines_string);
//var_dump($lines_string);
?>
這是工作,但是當我改變的URL https://google.com
不起作用,爲什麼?
它工作時,我直接用在這兩個情況(當我不使用htmlentities()
)... (我用http://phpfiddle.org/)
請比說更具體的「這是行不通的。」你看到了什麼結果?你期望什麼結果?如果有任何錯誤消息,請分享。 – Metropolis