inherited scope in a function (CFPARAM)

From: Indrid Cold (nobody_at_nowhere.com)
Date: 02/29/04


Date: Sun, 29 Feb 2004 15:44:40 GMT

Is there a way to call a function so the function shares the scope of the
caller?

For example, I was playing around with making a php version of the cold
fusion tag CFPARAM

What that cold fusion tag/sorta-function does is:
1) Check if a variable exists
2) If it doesn't, creat it with a default value

I could do it inline like this:
            eval("if(empty(\$testVar)) \testVar=null;");

but I don't see how I could do it as a function, like say
            phParam("test")
... is there any way for php to see all variables in the caller's scope
without passing them in or declaring them all global?



Relevant Pages

  • Re: variable scope
    ... >> out what the scoping rules are for php. ... > Because the lack of typing variables are always in the function scope. ... I tend to declare them close to where they are going to be used ...
    (comp.lang.php)
  • Re: [PHP] Odd PHP memory issue
    ... This MAY be fixed in current PHP -- I just know it was once an issue. ... references go out of scope or are unset. ... Forget "go out of scope" as a solution to memory management. ...
    (php.general)
  • Re: getting the variable name in php
    ... scope is that several variables might have the same value. ... modified to a random value to make sure there will be a unique match. ...
    (comp.lang.php)
  • Re: variable scope
    ... scope in terms of file and functions but not in terms of construct ... the construct scoping rules are for php. ...
    (comp.lang.php)
  • Re: inherited scope in a function (CFPARAM)
    ... Indrid Cold wrote: ... > Is there a way to call a function so the function shares the scope of the ... I was playing around with making a php version of the cold ... The good news is that you can quite easily solve the problem of passing ...
    (comp.lang.php)