note 91124 added to function.session-register
| From: | david dot demri at gmail dot com | Date: | Tue, 26 May 2009 14:15:50 +0000 |
| Subject: | note 91124 added to function.session-register | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156026@lists.php.net to get a copy of this message | ||
If you have an old code with a lot of call to the function session_register(), and you would like to
make it compatible with PHP5 or PHP6, instead of rewriting all your code by replacing this function
by $_SESSION['var']="val"; you could use the function set_session_vars(), that
is used exactly the same way than session_register() (but there is no implicit call to
session_start() ).
<?php
function set_session_vars() {
$nb_args=func_num_args();
$arg_list=func_get_args();
for($i=0;$i<$nb_args;$i++) {
global $$arg_list[$i];
$_SESSION[$arg_list[$i]] = $$arg_list[$i];
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 82.67.160.21
----
Manual Page -- http://www.php.net/manual/en/function.session-register.php
Edit -- https://master.php.net/note/edit/91124
Del: integrated -- https://master.php.net/note/delete/91124/integrated
Del: useless -- https://master.php.net/note/delete/91124/useless
Del: bad code -- https://master.php.net/note/delete/91124/bad+code
Del: spam -- https://master.php.net/note/delete/91124/spam
Del: non-english -- https://master.php.net/note/delete/91124/non-english
Del: in docs -- https://master.php.net/note/delete/91124/in+docs
Del: other reasons-- https://master.php.net/note/delete/91124
Reject -- https://master.php.net/note/reject/91124
Search -- https://master.php.net/manage/user-notes.php