5-2.php
来自「《php程序设计》的配套源码 《php程序设计》的配套源码 《php程序」· PHP 代码 · 共 28 行
PHP
28 行
<?php
function have_required($array, $required_fields) {
foreach ($required_fields as $field) {
if (empty($array[$field])) return false;
}
return true;
}
if ($submitted) {
echo '<p>You ';
echo have_required($_POST, array('name', 'email_address'))
? 'did' : 'did not';
echo 'have all the required fields.</p>';
}
?>
<form action="<?= $PHP_SELF ?>" method="POST">
<p>
Name: <input type="text" name="name" /><br />
Email address: <input type="text" name="email_address" /><br />
Age (optional): <input type="text" name="age" />
</p>
<p align="center">
<input type="submit" value="submit" name="submitted" />
</p>
</form>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?