note 57701 deleted from reserved.variables by mazzanet

From: Date: Sun, 25 Dec 2005 23:44:53 +0000
Subject: note 57701 deleted from reserved.variables by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-100709@lists.php.net to get a copy of this message
Note Submitter: sebastian dot holmqvist at gmail dot com ---- <?php //Set global variables function globalVars() { for($i = 0; $i < func_num_args(); $i++) { ${func_get_arg($i)} = (isset($_POST[func_get_arg($i)])) ? $_POST[func_get_arg($i)] : $_GET[func_get_arg($i)]; } } ?> I got tired of writing $globalvariable = $_POST['globalvariable'] etc when ever I had to edit an old php-script. So I made this up. Haven't exactly tried it but it shoudl work :) I.e: globalVars('firstname','lastname'); should set both variables to the $_POST and $_GET Enjoy!

« previous php.notes (#100709) next »