0
我需要能夠包括一個變量的URL,所以當我使用file_get_html我可以到我需要的特定頁面。使用PHP簡單的HTML DOM解析器url與PHP變量
這是我正在嘗試作爲一個測試。
$activity= 'com.google.com';
$html = file_get_html("https://play.google.com/store/apps/details?id=".$activity) or die('this is not a valid url');
echo $html;
活動是運行我的mysql_fetch_array時會發生什麼變化。我試過單引號,雙引號沒有引號,不能拿出解決方案。
我只是得到這不是一個有效的URL
如果我用這個,它的作品,因爲它僅更換基URL
$a = 'google.com';
$b = "http://" . $a . "/";
$html = file_get_html($b)
似乎訪問特定的URL時僅是一個問題
UPDATE 以上是不工作,因爲它不是一個有效的網址。當輸入一個有效的網址,它的工作。
但是,把我的現實世界中的場景,它說不是一個有效的URL
$html = file_get_html("https://play.google.com/store/apps/details?id=".$row['activity']) or die('this is not a valid url');
也許URL是指具有file_get_html問題到一個不存在的頁面? – 2014-09-03 15:22:45
儘管這裏看起來並不是問題,但您應該始終對要在urls中使用的變量進行編碼:'.... id =「。urlencode($ activity)...'。變量將無法打破/無效你的網址 – jeroen 2014-09-03 15:23:21
上述例子的問題是因爲沒有現有的頁面,但是當我把它放到我的真實世界場景中時,我得到了同樣的問題,這裏是代碼$ html = file_get_html(「 https://play.google.com/store/apps/details?id=".$row ['activity'])或死('這不是一個有效的網址'); – Bignadad 2014-09-03 15:28:43