这是我的一段代码(全身代码):
<body>
<script type='text/javascript'>
function AddEvent(Syear, Smonth, Sday, Eyear, Emonth, Eday, hallNumber){
...
}
</script>
<?php
function GetMonthByCoding($first , $second , $third) {
...
}
function GetDateByCoding($coding){
...
}
function GetDateFromLine($line){
...
}
$userid = '...';
$magicCookie = 'cookie';
$feedURL = "...";
$sxml = simplexml_load_file($feedURL);
foreach ($sxml->entry as $entry) {
$title = stripslashes($entry->title);
if ($title == "HALL") {
$summary = stripslashes($entry->summary);
$date = GetDateFromLine($summary);
echo ("<script type='text/javascript' language='JavaScript'> AddEvent(" . $date['start']['year'] . ", " . $date['start']['month'] . ", " . $date['start']['day'] . ", " . $date['end']['year'] . ", " . $date['end']['month'] . ", " . $date['end']['day'] . "); </script>");
}
}
?>
</body>
AddEvent()
是之前定义的JavaScript函数。entry as $entry) { $title = stripslashes($entry->title); if ($title == "HALL") { $summary = stripslashes($entry->summary); $date = GetDateFromLine($summary); echo (""); } } ?>
看起来它是一个回声但你可以看到在foreach中间没有回声。
谁能说我做错了什么?
答案 0 :(得分:3)
未安装PHP,或者未启用PHP,或者该文件不是.php
文件,或者未告知服务器将其识别为要解析的文件。
尝试View Source
,您应该会看到所有PHP代码。部分出现的唯一原因是因为浏览器认为从<?php
到第一个>
的所有内容都是无效标记。
答案 1 :(得分:0)
我发现了问题,它是以变量sxml的名义。我重命名了,问题就逃脱了。