php 中的无效参数
当我在 Wamp 中运行脚本时,我收到以下第 17 行和第 21 行的警告通知。这告诉我什么以及可以/应该做什么来解决该问题?
警告:在 C:\wamp\www\eCardScript\ecard_lib.php 第 17 行中为 foreach() 提供的参数无效 *警告:* 在 C:\wamp\www\eCardScript\ecard_lib.php 第 21 行 中为 foreach() 提供的参数无效
<?php
include('htmlMimeMail.php');
function getPostGetVars() {
global $HTTP_POST_VARS,$HTTP_GET_VARS;
foreach ($HTTP_POST_VARS as $key => $value) { // This is Line 17
global $$key;
$$key = $value;
}
foreach ($HTTP_GET_VARS as $key => $value) { // This is Line 21
global $$key;
$$key = $value;
}
}
?>
When I run a script in Wamp I get the following Warning Notifications for line 17 and 21. What is this telling me and what can/should be done to resolve the issue ?
Warning: Invalid argument supplied for foreach() in C:\wamp\www\eCardScript\ecard_lib.php on line 17
*Warning:* Invalid argument supplied for foreach() in C:\wamp\www\eCardScript\ecard_lib.php on line 21
<?php
include('htmlMimeMail.php');
function getPostGetVars() {
global $HTTP_POST_VARS,$HTTP_GET_VARS;
foreach ($HTTP_POST_VARS as $key => $value) { // This is Line 17
global $key;
$key = $value;
}
foreach ($HTTP_GET_VARS as $key => $value) { // This is Line 21
global $key;
$key = $value;
}
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请改用
$_GET
和$_POST
。http://php.net/manual/en/language.variables.predefined.php
从 PHP 5.0.3 开始,默认情况下禁用 HTTP_GET_VARS 等长预定义数组。为了向后兼容,您可以在 php.ini 中启用它们......
Use
$_GET
and$_POST
instead.http://php.net/manual/en/language.variables.predefined.php
From PHP 5.0.3 long predefined arrays such HTTP_GET_VARS got disabled by default. For backward compatibility you can enable them in php.ini....
$HTTP_POST_VARS
和$HTTP_GET_VARS
已弃用。您应该分别使用$_POST
和$_GET
。$HTTP_POST_VARS
and$HTTP_GET_VARS
are deprecated. You should use$_POST
and$_GET
respectively.