Posted: Thu Jan 04, 2007 6:36 am
I sifted through the thread in search for a conceivable problem for which this function would solve, but didn't find any. I think you may be a little confused about variable scope.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
That would return iamnotwhatyouareafter in the following snippet, while you seek the "mother" of $seekme:neel_basu wrote:Ya I've Got The idea In My Mind.We Can Do it
We Can Create A Funcion That Will Treat $_SERVER["PHP_SELF"] as a Text file
and search for the Variable name in it.
And Store the line number (s) of its occurences in an Array ( Suppose $arr_var ) descending
and Then search for the string "function" And store the line number (s) of its occurences in an another array ( Suppose $arr_func ) descending
As Occurences of one variable in a Function may be 1 or many so
in a for loop it Would first hold the $arr_var[$i] and then start another loop
for($j=0;$j<=$arr_var[$i];$j++) And Find the nearest line number ( nearest with $arr_var[$i] ).
And In that line The mother Function Stayes
So Now we will find the String after "function " and before "(" and trim() it To get The Function name
and that function would take the variable name (as string) as argument
and make output of the name of the function(s) (as string) if more than 1 function names are found it would use a separater as "-" or "," and return the string
( We Can explode it latter fo further use )
Code: Select all
function iamnotwhatyouareafter() {
...
}
$seekme = true;Code: Select all
$iamaglobalvariable = true;
function firstlevelfunction() {
function secondlevelfunction() {
...
}
$seekme = true;
}Thanks.szaky wrote:That would return iamnotwhatyouareafter in the following snippet, while you seek the "mother" of $seekme:
Ok, in that case the var $seekme is a global variable, not a local.Code: Select all
function iamnotwhatyouareafter() { ... } $seekme = true;
Before You mention that, here's another:
=========================================================Your "parser" would return the secondlevelfunction whilst should return firstlevelfunction.Code: Select all
$iamaglobalvariable = true; function firstlevelfunction() { function secondlevelfunction() { ... } $seekme = true; }
Anyway, when You refer to $_SERVER["PHP_SELF"] keep in mind, that it points to the actual php script, so You don't really want to use it in your "parser", do you?
Cheers.