Forum Moderators: coopster

Message Too Old, No Replies

Pull and dump variables from and to parent scope.

Attempt at pseudo Python-styled variable arguments in PHP. :)

         

ltboy

5:21 am on Jun 9, 2005 (gmt 0)

10+ Year Member



Ok, I'm trying to create a simple(or not so simple) function that takes a string or strings containing python style arguments(funtion(arg1=value1, arg4=value3, arg3=value4)) and parses them into actual data to be used.

My function'll probably just accept one string, in the form of 'arg1=value1, arg4=$value3, arg3=value4'. In this case, I'd want to pass $value3 by reference as arg4, otherwise, I'd just use double quotes and pass the value of $value3.

Passing only the value also kills array and object values...

So basically, I need to know if and how I can pull variables from ONLY the parent scope's parent scope.

I.E.:
global scope
_some_function
__the_function_with_python_styled_args
___the_argument_parser_call

The argument parser function would need grab variables from "_some_function" ONLY without pulling from the global scope and would, on exit have to dump variables into "__the_function_with_python_styled_args".

I know that the second task can be done, I just don't know how, It's the first task, pulling variables(preferably by reference) from a specific scope, that I'm really stumped on.

Thanks in advance for any help, and until then I'll just keep googleing.

JamShady

3:29 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



You could use the debug backtrace to get the values of variables, but you wouldn't be able to access them directly (i.e. it won't mimick passing by reference)