[geeklog-devtalk] Variable best practices

Blaine Lang geeklog at langfamily.ca
Sun Feb 29 10:19:00 EST 2004


As a practce, I try not to have any register_globals dependancies. I will use the full $HTTP_POST_VARS and $HTTP_GET_VARS variable names. I'd lole to use the other supper globals ($_REQUEST, $_POST and $_GET) and are still dependant on php version 4.1 or greater. Most hosting services should be running by now but it can not be assumed I guess.

I'm filtering all expected POST and GET vars now in my new plugins and there are still times it makes sense to use the same name in the POST and GET. It may be passed in the URL or form so you have to check both but I check the post first as I would use that first if I can post a hidden variable.

Examples are:
using $op to indicate operation. I may be triggered from a link, selectbox, image or button in the UI. I may also have to pass it to another script.
using $page and $sort as part of the page google like navigation (links) but you also need to retain this as hidden fields in forms if you want to retain your page position.

I don't see the reason to use different names with the get and post as this allows me more control. I only expect it one way or the other and POST should override get.

Hense why I end of having all this extra code at the top of scripts:

> if (isset($HTTP_POST_VARS['op']) ) {

> $op = clubApplyFilter($HTTP_POST_VARS['op']);

> } elseif (isset($HTTP_GET_VARS['op']) ) {

> $op = clubApplyFilter($HTTP_GET_VARS['op']);

> } else {

> $op = '';

> }


Is this how others would approach this?

I was thinking if I am having to repeat this practice and common code, others would as well. Extending my class object to handle this would be an advantage.
$myfilter = new COM_filter;
$myfilter->_censor = true;
$myfilter ->_jsfilter = true;
$op = $myfilter->_setvar('op', 'text');

Cheers,
Blaine

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://eight.pairlist.net/pipermail/geeklog-devtalk/attachments/20040229/7c3b5463/attachment.html>


More information about the geeklog-devtalk mailing list