所以我有以下内容:
<?php
show_form();
?>
<form id="add" method="post" action="addIssue.php">
Name:
<?php input_text('name','str_name', $defaults , '1'); ?>
<input class="submit" type="submit" value="Begin download" />
<input type="hidden" name="_submitCheck" value="1"/>
</form>
<?php
function show_form($errors = '')
{
// If form is submitted, get the defaults from submitted parameters
if(empty($_POST['_submitCheck']) OR !$_POST['_submitCheck'] ){
// set our own defaults
$defaults = array('str_name' => '');
} else {
$defaults = $_POST;
}
}
// Echo text box
function input_text($elem_id, $element_name, $values, $tab='') {
echo '<input id="'.$elem_id.'" name="'.$element_name.'"';
echo ' tabindex="'.$tab.'" class="text" value="';
echo htmlentities($values[$element_name]) . '" />';
}
?>
Run Code Online (Sandbox Code Playgroud)
为什么我收到以下通知?
Notice: Undefined variable: defaults
$defaults是show_form函数范围内的局部变量.您将要从函数返回它并将第一行代码更改为:
$defaults = show_form();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
261 次 |
| 最近记录: |