【发布时间】:2012-02-04 03:28:08
【问题描述】:
我尝试使用的一些 PHP 代码有问题。我不断收到“意外的 T_STRING”错误?这是我的测试页面上的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
include 'http://www.weather.gov/xml/current_obs/KTPA.xml';
$current_observation = new SimpleXMLElement($xmlstr);
echo $current_observation->location[0]->plot;
echo $current_observation->weather[0]->plot;
echo $current_observation->temperature_string[0]->plot;
echo $current_observation->wind_string[0]->plot;
?>
我想做的是从这个 National Weather Service XML 文件中提取天气数据,并以类似于 NWS 在该页面上的方式显示它。但是,上面的代码返回此消息:“解析错误:语法错误,第 1 行 http://www.weather.gov/xml/current_obs/KTPA.xml 中的意外 T_STRING”。这是我可以解决的问题吗?我是 PHP 新手,如果您能提供任何帮助,我们将不胜感激。
【问题讨论】:
标签: php