Page 1 of 1

cleaning up my code

Posted: Wed Feb 25, 2004 1:46 pm
by d3ad1ysp0rk
usually, if i have a bunch of things passed session or form-wise, i like to make them into normal variables, to make them easier to reference, like so:

Code: Select all

$id = $_SESSION['id'];
$page = $_GET['page'];
$date = $_GET['date'];
$amt = $_POST['amt'];
$type = $_POST['type'];
and so on. but that gets really tedious after awhile, and i remember finding a MUCH better way of doing it.

I believe it did something like run through each thing (post, get, session, etc) and then created a variable for each?.. but i have no idea how to do it, so i was wondering if anyone knows what im talking about

thanks

Posted: Wed Feb 25, 2004 2:04 pm
by xisle

Posted: Wed Feb 25, 2004 2:40 pm
by d3ad1ysp0rk
Thanks, I use this if anyone wanted to know (or improve on it :P ):

Code: Select all

if(count($_POST) > 0){ extract($_POST, EXTR_SKIP); }
if(count($_GET) > 0){ extract($_GET, EXTR_SKIP); }
if(count($_SESSION) > 0){ extract($_SESSION, EXTR_SKIP); }
if(count($_COOKIE) > 0){ extract($_COOKIE, EXTR_SKIP); }

Posted: Wed Feb 25, 2004 8:58 pm
by AVATAr
$_REQUEST ?