有人可以帮我鉴定在这里的错误:与文件PHP错误获取内容
<?php
$city=$_GET['city'];
$city=str_replace(" ", "", $city);
[email protected]_get_contents("http://www.weather-forecast.com/locations/'.$city'/forecasts/latest");
preg_match('/<span class="phrase">(.*?)</s', $contents, $matches);
echo @$matches[1];
?>
出于某种原因的代码是给我的错误,但是,如果我删除了城市和特定城市进行更换(伦敦,巴黎,开罗)的代码工作,但是当我把它放在城市..代码不起作用。
有人可以帮助我确定错误或如何工作。
改变这个'“http://www.weather-forecast.com/locations/'.$city'/forecasts/latest”''到“http://www.weather-forecast.com/locations/$city/forecasts/latest”'。然后尝试 –
重新格式化您的问题(不需要粗体)。在执行$ contents行之前,$ city的价值是多少? –
字符串连接出现错误。 –