Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusion in PHP variables

Tags:

php

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?

like image 257
Webroots Avatar asked May 02 '26 20:05

Webroots


1 Answers

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

like image 162
Dan Grossman Avatar answered May 04 '26 11:05

Dan Grossman