2
我想獲得一個代碼腳本的工作,但我得到
未定義的變量:http_response_header
錯誤。我搜索了一下,發現$ http_response_header是全局的,並且內置到php中,爲什麼我會得到這個錯誤。我正在使用安裝PHP 5.4的wamp。這裏是我的代碼:
$url="https://data.mtgox.com/api/2/BTCCAD/money/ticker";
$json = @file_get_contents($url);
//check for errors
if (strpos($http_response_header[0], "200")) {
// On success, decode JSON
$data = json_decode($json);
感謝 艾哈邁爾
你在哪裏讀了'$ http_response_header'是全球性的? – Fractaliste
該文檔明確指出'$ http_response_header'不是全局的。 http://www.php.net/manual/en/reserved.variables.httpresponseheader.php我建議反正使用cURL。 – Brad
@Brad我正試圖讓這個股票工作。但是它使用http標題響應http://skybin.net/bitcoin-ticker-on-your-website/ –