错误报告不会在以前的服务器上包含通知,这就是为什么您没有看到错误的原因。
您应该在尝试使用索引之前检查索引是否
s确实存在于
$_GET数组中。
这样的话就足够了:
if (isset($_GET['s'])) { if ($_GET['s'] == 'jwshxnsyllabus') echo "<body onload="loadSyllabi('syllabus', '../syllabi/jwshxnporsyllabus.xml', '../bibliographies/jwshxnbibliography_')">"; else if ($_GET['s'] == 'aquinas') echo "<body onload="loadSyllabi('syllabus', '../syllabi/AquinasSyllabus.xml')">"; else if ($_GET['s'] == 'POP2') echo "<body onload="loadSyllabi('POP2')">";} else { echo "<body>";}使用
switch语句使代码更具可读性可能会有所帮助(如果您打算增加更多的案例)。
switch ((isset($_GET['s']) ? $_GET['s'] : '')) { case 'jwshxnsyllabus': echo "<body onload="loadSyllabi('syllabus', '../syllabi/jwshxnporsyllabus.xml', '../bibliographies/jwshxnbibliography_')">"; break; case 'aquinas': echo "<body onload="loadSyllabi('syllabus', '../syllabi/AquinasSyllabus.xml')">"; break; case 'POP2': echo "<body onload="loadSyllabi('POP2')">"; break; default: echo "<body>"; break;}编辑:顺便说一句,我编写的第一组代码模仿了您的全部意图。意外值的预期结果是否
?s=意味着不输出
<body>标签,或者这是疏忽?请注意,该开关将始终通过默认设置来解决此问题
<body>。



