Re: notice and warning
- From: Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@xxxxxxxxxxxxxxxx>
- Date: Tue, 22 Jul 2008 15:08:59 +0200
Barry schreef:
"Erwin Moller" <Since_humans_read_this_I_am_spammed_too_much@xxxxxxxxxxxxxxxx> wrote in message news:487e1e6b$0$14347$e4fe514c@xxxxxxxxxxxxxxxxxJeff schreef:
<snip>
Don't use $_REQUEST[].
Use $_POST or $_GET or $_COOKIE or whatever you need, but don't use $_REQUEST.
Doing so means you don't know where your data comes from.
(Some people, like me, think it should never have been added to the language.)
Hi Barry,
Sorry for late response: I have been working way too much hours elsewhere the last few days. Back now. :-)
what's wrong with $_REQUEST, erwin? i use it as standard practice. i have the order set in the php.ini to my liking - it happens to be the default. if i need to get fussy where my data is coming from, then i specifically use the one i need, i.e. $_POST/GET/COOKIE et. al.. using $_REQUEST scales better also since you may change your implementation on how the script is being called/used. being specific when not needed means you'll have to re-write that portion of the script...not so with $_REQUEST.
just wondering what your reasoning is.
An example:
You expect some piece of data from a post in your script, eg: userid.
So you use $_REQUEST["userid"] which works perfectly fine as long as you get the userid in via POST.
Let's say this script deletes user the user: userdelete.php
So we have userdelete.php that expects a userid from POST.
Now suppose you leave your fine-running app for a year or so, untill your client wants some upgrades to it.
In some unrelated part of your app you decide to store a userid in the $_SESSION so you have it easy at hand on some other pages. The userid contains the userid of the currently logged in user.
Now you find yourself in the situation that when you call this script for any reason without the POST info, you will delete yourself if you prefer $_REQUEST over $_POST.
Same can happen with get of course.
Of course, all this can be avoided easily if your program perfectly and never make mistakes, but I doubt that. ;-)
So, in my opinion, it is always better to state where you get your data from.
If we stick to your example: You say using $_REQUEST scales better.
I say it bugs better. ;-)
Regards,
Erwin Moller
.
- Follow-Ups:
- Re: notice and warning
- From: Dale
- Re: notice and warning
- References:
- notice and warning
- From: Jeff
- Re: notice and warning
- From: Erwin Moller
- Re: notice and warning
- From: Barry
- notice and warning
- Prev by Date: Re: Does apache stop a script mid execution ?
- Next by Date: Library versions in PHP
- Previous by thread: Re: notice and warning
- Next by thread: Re: notice and warning
- Index(es):
Relevant Pages
|