簡體   English   中英

file_get_contents()無法用於2個網址

[英]file_get_contents() not working for 2 url's

我正在使用file_get_contents()函數從Google獲取兩個網頁。 我的代碼是:

var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));

var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=ice&start=00'))));

file_get_contents函數適用於第一個URL,但不適用於第二個URL。 有什么問題?

這是因為存在字符, htmlspecialchars無法處理。 file_get_contents正在工作。

嘗試ENT_SUBSTITUTE選項:

var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));

https://secure.php.net/manual/en/function.htmlspecialchars.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM