Kevin Yank的教程中的 php 'if statement' 示例似乎不起作用。具体来说,条件的两个分支都会在页面加载时出现。我还尝试更改为非速记“if”语法,但无济于事。问题不是语法吗?
代码如下:
<!DOCTYPE html>
<html>
<head>
<title> Sample Page </title>
</head>
<body>
<?php if(isset($name)) : ?>
<p> Your name: <?php echo ($name); ?> </p>
<p> This paragraph contains a <a href="goodone.php"> link</a> that passes the name variable on to the next document. </p>
<?php else : ?>
<!-- No name has been provided, so prompt the user for one -->
<form action="<php echo($PHP_SELF); ?>" method="get">
Please enter your user name:
<input type="text" name="name">
<input type="submit" value="ok">
</form>
<?php endif; ?>
</body>
</html>