Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6985861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:44:05+00:00 2026-05-27T18:44:05+00:00

Possible Duplicate: Is using $GLOBALS['HTTP_GET_VARS'] deprecated? Invalid arguements in php I get the following

  • 0

Possible Duplicate:
Is using $GLOBALS['HTTP_GET_VARS'] deprecated?
Invalid arguements in php

I get the following response when I run script in a WAMP environment:

Warning: Invalid argument supplied for foreach() in
C:\wamp\www\GeCard\eCardScript_ecards\ecard_lib.php on line 17

Warning: Invalid argument supplied for foreach() in
C:\wamp\www\GeCard\eCardScript_ecards\ecard_lib.php on line 21

This is my code:

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

I am told that this code is deprecated. Can this piece of code be easily updated to eliminate the warnings?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:44:06+00:00Added an answer on May 27, 2026 at 6:44 pm

    Use $_POST and $_GET instead of $HTTP_POST_VARS and $HTTP_GET_VARS respectively.

    function getPostGetVars() {
      foreach ($_POST as $key => $value) {  //This is line 17
        global $$key;
        $$key = $value;
      }
      foreach ($_GET as $key => $value) {   //This is line 21
        global $$key;
        $$key = $value;
      }
    }
    

    If you check the manual pages for $_POST and $_GET, you’ll see that their more verbose counterparts have been deprecated.


    I can’t help but notice what you are trying to do with this code essentially mirrors the function of extract(). I would caution you from doing this because an attacker could rewrite essential variables (say $isLoggedIn) with a request and exploit the server. If you continue to do something like this I suggest using extract() with a flag such as EXTR_PREFIX_ALL so that there are no collisions. You can prefix the get variables with get_ and the post variable with post_, for example.

    However, unless you truly know what you’re doing, using extract like this (or your method) is extremely dangerous in a production environment. I would advise against it completely and instead use the proper super globals to access the $_GET and $_POST variables.

    See this post by Marc B on this vulnerability for more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PDO Prepared Statements I'm using the mysqli extension in PHP and I'm
Possible Duplicate: PHP global in functions Using something like this worries me: <? global
Possible Duplicate: using mysql_close() Are mysql_close and pg_close required ? In some script there
Possible Duplicate: Using Memcache vs Memcached with PHP Someone can explain me the difference
Possible Duplicate: php using special symbols (<?php echo $row_pageDetails['profile']; ?>) If profile is empty
Possible Duplicate: Using a javascript variable to set PHP variable I need to do
Possible Duplicate: encode json using php? $hello_world = $this->session->all_userdata(); foreach($hello_world as $key=>$product_id) { $query['products']
Possible Duplicate: using jquery $.ajax to call a PHP function I need to call
Possible Duplicate: using seo user friendly in php I have 3 PHP files: index1.php,
Possible Duplicate: mysql: Using LIMIT within GROUP BY to get N results per group?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.