Is it possible that variables are not always case sensitive? When I moved my website from the local environment to the web server, a lot of things stopped working and had to be fixed. Among one of the things was that I had assigned variables $userid and $charid and then tried to address them as $userId and $charId, with the Id starting with a capital letter. Yet it appears that that somehow worked locally, because it certainly didn't fail like it did online.
Also, in a lot of places I was referring a variable as $userid which wasn't defined anywhere on the page, (the actual name of the variable was $currentUser) yet somehow it never failed to work. The value of the variable was placed in a hidden field in a form, and if the next page didn't have the GET variable then it should fail. Yet somehow it was working. It totally blows my mind. It must've been getting the $userid definition from somewhere but I can't see how or where. Um, is it possible that something in some versions of php automatically converts GET information into variables with the same name? That's the only explanation I could think of. Maybe this is far fetched but I am totally baffled about how it's even vaguely possible the code was working in the first place with all the bugs.
Variable confusion
Moderator: General Moderators
Re: Variable confusion
Variables are always case-sensitive.Seeeks wrote:Is it possible that variables are not always case sensitive?
The feature was called register_globals and was removed in PHP 5.4. It worked just as you said.Seeeks wrote:is it possible that something in some versions of php automatically converts GET information into variables with the same name?
Re: Variable confusion
That explains it, although I will forever be wondering how on earth the code was working with mismatched case.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Variable confusion
My guess is that register_globals was on. However, it might have been issuing a warning that the variable was not defined, but the code still worked with those vars undefined. An upgrade may have changed a warning to an error.Seeeks wrote:That explains it, although I will forever be wondering how on earth the code was working with mismatched case.
(#10850)