Hi everybody,
I need to convert a variable into a super global one , without using cookies and sessions , is that possible?!
And if so , How ?!!
Thanks in advance ..
I need to turn a variable to a super global
Moderator: General Moderators
1) You can't.
2) It's a bad idea anyway, you should consider a different design.
3) If you really REALLY want to, you could do something like:
But, did you mean a global or a persistent variable?
2) It's a bad idea anyway, you should consider a different design.
3) If you really REALLY want to, you could do something like:
Code: Select all
$myvar =1234;
$GLOBALS['myvar'] = $myvar;
// in a different scope:
echo $GLOBALS['myvar'];Re: I need to turn a variable to a super global
Sure its possible.Mosab wrote:Hi everybody,
I need to convert a variable into a super global one , without using cookies and sessions , is that possible?!
And if so , How ?!!
Thanks in advance ..
Code: Select all
$whatever = 'important variable to put in the super global area';
$_REQUEST['whatever'] = $whatever;The bigger question is why you want that. More likely, you want global, not super-global. In that case, you'd do:
Code: Select all
global $whatever;
$whatever = 'important variable to put in the super global area';But again, its important to ask why you need it global. Your design probably needs more thought if you need more than a few globals.