-
$GLOBALS in a function
Hello,
I am writing alot of functions for my website in php, and in almost every one, It requires a variable outside of the functions. So thats why the invented $GLOBALS. But, It gets to be a pain writing out $my_var = $GLOBALS['myvar']; for every stupid function, especially when there's over 20 that I need. And there is no way will I put all 20 variables in the calling perenthese.
I tried a for-loop but every time I attempt, I always get: Phrase Error: da-da-da-da-da... Can someone please make a simple for loop that changes all globals into varables. Thanks in advance.
~FSD
-
-
foreach ($GLOBALS as $k=>$g) {
$$k = $g;
}
to return them:
foreach ($GLOBALS as $k=>$g) {
$tempglobals[$k] = $$k;
}
$GLOBALS = $tempglobals;
Last edited by djr33; 10-19-2007 at 10:38 PM.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks