"Kevin Thorpe" <ke***@pricetrak.com> schrieb im Newsbeitrag
news:40**********************@news.easynet.co.uk.. .
Sims wrote:
Is it wrong to forcefully set a value HTTP_GET_VARS and HTTP_POST_VARSFeel free to do that if you wish. It will only exist until the end of
this script though.
Yes sorry that is what i should have said.
if( !$HTTP_GET_VARS['foo'] ){
$HTTP_GET_VARS['foo'] = 'bar';
}
...
it would make it easier for me to assume that $HTTP_GET_VARS['foo']
exists by forcefully setting it at the beginning of the script.
Absolutely fine. That's probably good practice, while you're at it you
should check that the sent value is reasonable.
It seems wrong to me to create a variable that looks like a get variable but
is none. Why not:
if(isset($_GET['foo'])) {
$foo = $_GET['foo'];
}
else {
$foo = "bar";
}
If you extract all your request variables like that before processing them
you have a transparent code. (If $foo can be transmitted with either get or
post, just check for $_REQUEST['foo']). Also it is easier to write $foo than
$_GET['foo'] or even $HTTP_GET_VARS['foo'] all the time.
Imagine your script is 400 lines long, and anywhere your above code appears.
In 2 years you have to make a modification, it will take you an hour to
figure out why there is a value for a field that you did not submit!
HTH
Markus