这是我的一段代码(全身代码):
<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) { $title = stripslashes($entry->title); if ($title == "HALL") { $summary = stripslashes($entry->summary); $date = GetDateFromLine($summary); 回声(“”);} } ?>
看起来这是一个回声,但你可以看到在 foreach 中间没有回声。
谁能说我做错了什么?