Invalid arguements in php

两盒软妹~` 提交于 2019-12-02 18:07:58

问题


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;
  }
}
?>

回答1:


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....




回答2:


$HTTP_POST_VARS and $HTTP_GET_VARS are deprecated. You should use $_POST and $_GET respectively.



来源:https://stackoverflow.com/questions/8561822/invalid-arguements-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!