gpt4 book ai didi

xampp - $_POST 的未定义索引(菜鸟问题!)

转载 作者:可可西里 更新时间:2023-11-01 13:48:20 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”

我刚开始学习 PHP,但一直收到未定义索引错误。我正在学习的书有一个 HTML 表单和一个使用以下格式处理该表单的 PHP 页面:

<!-- The form fields are all set up something like this -->
<input type="text" id="howlong" name="howlong" /><br />

// The PHP starts with one line like this for each of the form fields in the HTML
$how_long = $_POST ['howlong'];

// And there is one line for each one like this to output the form data:
echo ' and were gone for ' . $how_long . '<br />';

我正在使用的示例有大约 12 个表单域。

奇怪的是并不是所有的变量都会抛出这个错误,但我看不到它的模式。

我检查了所有 HTML 字段名是否与我输入的 PHP $_POST 变量名相匹配,并且我确定当我填写并提交表单时,所有字段都填写了一些内容。有趣的是,可以为本书下载的完整代码也抛出此错误。

我意识到这段代码可能没有反射(reflect)最佳实践,它来自本书的第一章,显然我是一个菜鸟 :)

以防万一,我在 XAMPP 1.7.4 和 Windows 7 家庭高级版上使用 PHP 5.3.5。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com