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 8334171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:15:31+00:00 2026-06-09T03:15:31+00:00

I came across a bit of code working in someone else’s code for a

  • 0

I came across a bit of code working in someone else’s code for a form validator. It was supposed to return a value from the form data posted. Anyway, it was always returning NULL. This is what the function was in its entirety (the assumption is that this code did work at one point):

function _getValue($field)
{
    global ${$field};
    return ${$field};
}

From the context in the other functions, I could tell it was trying to get the value from the (in this case) $_POST variable. When I changed the function to the following, everything worked like a charm:

function _getValue($field)
{
    // $_REQUEST should hold $_GET and $_POST values
    return $_REQUEST[$field];
}

So my question is… what the heck is global ${$field} mean in this context? I know what ${$field} is, but let’s say they passed in email to that function. Where is this global $email variable coming from?

How is the original function supposed to have worked? I know there’s something called “Super Globals” or something and that’s bad. Is this related? Is that possibly why it stopped working? Did the host turn off Super Globals?

[EDIT] There was some obviously confusion in the way I phrased the question. I know what ${$field} and $$field means, but I don’t know how

global ${$field};
return ${$field};

returns the value the user put into a form like

<input name="email">

when you call

$this->_getValue('email');
  • 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-06-09T03:15:33+00:00Added an answer on June 9, 2026 at 3:15 am

    The programmer before you expected the POST variables to be in the global space, because of the register_globals directive. Thankfully, this feature has been turned off by default in PHP 4.2 and removed in PHP 5.4.

    To quote the documentation:

    When on, register_globals will inject your scripts with all sorts of variables, like request variables from HTML forms.

    I wonder how could anyone think that was a good idea 🙂

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

Sidebar

Related Questions

I recently came across a bit of not-well-tested legacy code for writing data that's
I'm maintaining some existing pages and came across a bit of code from System.Threading
I recently came across this genius bit of code on HTTP POST from PHP,
I'm disassembling a bit of code and I came across: mov eax, cr3 mov
I've already got a bit of working code but I need someone to help
I thought I understood variable scope until I came across this bit of code:
I came across this bit of vba code posted in another SO question. Is
So I came across this bit of php code: <?php $long_url = http://example.com; $bit_ly
Hi I came across this bit of C++ code and am trying to learn
I came across this bit of code: n = args[0] as Long [*n..1, n].any{

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.