just replace $var with $GLOBALS['var'] where you want a global 
no matter what.

However, I would also welcome macros.

At 18:16 14.2. 2001, John Woolbright wrote the following:
>Is there any way in php to create macros for inline execution of code
>without creating scoping issues like function() does.  For Example:
>if you had a macro set up so like this
>Macro($x) {
>    for($i=0;$i<$x;$i++) {
>        echo $x;
>    }
>and a program like this
>you could call this macro an php would basically make the substitutions
>and execute the code within the current scope of the program without
>dropping into the scope of a function.  Although this would be
>inefficient for most things it could be a useful for some applications.
>The reason I am looking to do this is because I have a very large
>codebase of php scripts that are broken into modular pieces.  I have a
>function called Uses($includes) that allows you to pass in a string of
>include files.  Uses() runs through a loop to include the files but,
>because Uses is a function all variables within the included files go
>out of scope when the function executes.  Many of the included files
>have defined global variables that are defined for use with the included
>file.  If there were some sort of Macro syntax then every time the Macro
>is called the code is copyied and in-lined executed within the current
>running scope.  There may be way to do this.  For some scripts with
>complicated and nested includes the uses() function might get called
>several times to include files needed by submodules of modules.  I could
>do this with the include function but the way we have it set up it makes
>the scripts easier to read.
>i.e. Uses("Sql Date Http Browser") would include the sql.inc date.inc
>http.inc and browser.inc without having to specifiy
>the current uses function looks like this
>Uses ($includes);
>  $libs=explode(" ",$includes);
>  for ($i=0;$i<count($libs);$i++) {
>    $filename= trim(strtolower($libs[$i])) . '.inc.';
>    include($filename);
>  }
>Any feedback would be appreciated.
>John Woolbright
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
------end of quote------ 


A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.


PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to