我是php新手,我在大多数代码中遇到以下错误。 而不是输出,解析错误(!)解析错误:语法错误,第12行出现意外'='。每个代码都会显示此错误。
<html>
<head>
<title>Check For Blank Text Boxes</title>
</head>
<body>
<?php
$first ="";
$second = "";
function display_error_message($user_text) {
if ($user_text = = "") {
print "One or more blank text boxes detected";
}
else {
print "Text boxes OK";
}
}
if ($_SERVER['REQUEST_METHOD'] = = 'POST'){
$first = trim($_POST['first']);
$second = trim($_POST['second']);
display_error_message($first);
display_error_message($second);
}
?>
</body>
<FORM Method = "POST" action ="formFunction.php">
First Name: <INPUT TYPE = "text" name = "first" value ="<?=$first?>">
Surnmae: <INPUT TYPE = "text" name = "second" value ="<?=$second?>">
<input type="submit" name="Submit" value="Submit">
</FORM>
</html>
答案 0 :(得分:1)
试试这个,
if ($user_text == "") {
}
问题是&#39; =&#39;之间的空间。迹象
答案 1 :(得分:0)
比较php中使用的值== not = =。