3

Can we use the same variable name in PHP which is used to GET the data. Example: Get variable is $_GET['V'], now can I use $V variable for some other purpose or it will lead to ambiguity?

4 Answers 4

3

$_GET['V'] and $V are in no way tied together and will occupy different memory. You can use both names.

If you change the default PHP configuration to enable register_globals, $V would be created as well as $_GET['V'] if such a query string parameter existed, but you could still overwrite it and use it as a separate variable.

register_globals has not been enabled in the default PHP configuration for several years.

Sign up to request clarification or add additional context in comments.

Comments

0

It depends on php.ini configurations file's register_globals settings

1 Comment

Before PHP 4.2 it was set to on, this feature has been set to off by default since PHP 4.2.0, is DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.
0

You can use $V, just make sure register_globals is off, otherwise $V will be inicialized with the value of $_GET['V'] (but they will remain different vairables, so assigning value to $V won't affect $_GET['V'])

Comments

0

Yes, if register_globals are off - and it should.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.