IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New anything special about $_request?
it may be he just wanted to determine a request from a different action for rememberability. I wouldnt do it that way
New Special variable in PHP
$_POST is an array of any variables received via HTTP_POST. $_GET is an array of ... well, yeah. And there's also $_COOKIE. $_REQUEST is all of the above. All of these are there automatically, in global scope, and can't be modified.

The only reason (I can think of) to copy those variables out to something else is if you want to modify them. But that's not what's happening. He's just renaming them.

The amount of copy/paste is also impressive. I'm thinking total LOC could drop by ~30% just by refactoring without changing any functionality.
--

Drew
New Actually, they can be modified.
I've got code that sets a value in $_REQUEST as part of the page initialization: it actually checks to see if an entry is set and if not, provides a default. This is because there is scads of code that just uses the entry in $_REQUEST without checking to see if it is even there...

(I filed a bug that PHP's default error level should include Notices turned on. They closed it as not a bug, citing the docs that say you should change it for development, but ignoring the fact that many developers never touch the php.ini file.)

I think what your programmer is doing is avoiding continually referencing $_REQUEST, perhaps under some impression that a direct variable lookup is faster than an array lookup. Or should I say, that it is faster enough to make a difference.

Wade.

Q:Is it proper to eat cheeseburgers with your fingers?
A:No, the fingers should be eaten separately.
New Did not know that
It's been a while since I read the docs, so it's likely my recollection that "you can't change them" was based more on how you should do things than the mandates of the language. Changing a $_REQUEST value makes about as much sense as changing a $_SERVER variable. Even if you can, I really don't think you should.
--

Drew
New I was rather glad it was possible.
But I don't like it, either. When I have opportunity (which doesn't happen as often as I would like), I refactor code that relies on that trick to not rely on that trick. Many other improvements often happen at the same time...

Wade.

Q:Is it proper to eat cheeseburgers with your fingers?
A:No, the fingers should be eaten separately.
New If speed counts ...
As a general rule, 2 accesses via index or hash is the limit of how many times I'll touch a variable before I decide to rewrite an pull it into a local one and all accesses are from the local one that moment forward.

Also, some languages do reference by default so variables are modifiable and can be broken by accident, so some programmers get into the habit of doing a local copy for safety.
     Why would you rename variables? - (drook) - (13)
         I'd suspect reuse of another routine. - (Another Scott) - (2)
             Oh, it's definitely *not* to avoid globals - (drook) - (1)
                 Sounds like one of my old QuickBasic programs. =( -NT - (Another Scott)
         Re: Why would you rename variables? - (boxley) - (7)
             Not quite - (drook) - (6)
                 anything special about $_request? - (boxley) - (5)
                     Special variable in PHP - (drook) - (4)
                         Actually, they can be modified. - (static) - (2)
                             Did not know that - (drook) - (1)
                                 I was rather glad it was possible. - (static)
                         If speed counts ... - (crazy)
         There is, but it doesn't look like that's what is being done - (malraux) - (1)
             Like I told Wade, I didn't think that was an issue here - (drook)

It so happens I'm half Chinese, half Cajun. There probably isn't an animal that creeps through the forest of swims in the water that's safe from me.
42 ms