我尝试在<!doctype>
上方会话..但是当我使用 PHPtester 检查语法时.输出为:
"致命错误语法错误,第 1 行上出现意外的'is' (T_STRING(">
语法:
<?php session_start(); ?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<body>
<form id="userForm" method="post" action="form-process.php">
<div>
<fieldset>
<legend>User Information</legend>
<div id="errorDiv">
<?php
if(isset($_SESSION['error']) && isset($_SESSION['formAttempt'])){
unset($_SESSION['formAttempt']);
print "Errors encountered<br />n";
foreach($_SESSION['error'] as $error){
print $error."<br />n";
} //end foreach
}//end if
?>
</div>
你说的是 http://phptester.net/吗?这太荒谬了,它改变了检查的代码。
尝试 http://sandbox.onlinephpfunctions.com/- 您的代码在那里很好。