To be honest I don't understand some things neel_basu sais, so a little piece of advise to ya neel_basu: please try to be as concise and thorough as possible. I understand english may not be your native tongue, so when you are brief and unspecific the language barrier grows.The Ninja Space Goat wrote:what's the deal with this response?
You've said that in a few threads... what does that mean??To hug php While playing With it
![]()
Mother Function of A local variable
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- neel_basu
- Forum Contributor
- Posts: 454
- Joined: Wed Dec 06, 2006 9:33 am
- Location: Picnic Garden, Kolkata, India
I was joaking
Actually I learnt php While playing with it
And I love it
and so
If php is a female human being
i wanna get a hug from her.
I think hug is an English Word.
And I love it
and so
If php is a female human being
I think hug is an English Word.
Last edited by neel_basu on Wed Jan 03, 2007 11:42 pm, edited 1 time in total.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Mother Function of A local variable
It is a question that shows a wonderful depth of misunderstanding. Obviously because multiple functions can have local vars with the same name you couldn't get a definitive answer even from a parser that parsed the script. If you "have" (the word "have" has no real technical meaning) a local variable name then you can only really be in the function in which it exists, therefore __FUNCTION__ would work without even having the name.neel_basu wrote:Can We know In which function does a local variable is staying just with its name.
I mean
I have a local variable name
and i wanna know its from which function
(#10850)
- neel_basu
- Forum Contributor
- Posts: 454
- Joined: Wed Dec 06, 2006 9:33 am
- Location: Picnic Garden, Kolkata, India
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 )
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 )
- neel_basu
- Forum Contributor
- Posts: 454
- Joined: Wed Dec 06, 2006 9:33 am
- Location: Picnic Garden, Kolkata, India
It would Use fopen() to open the File And fread() to read it So It Would Not Parse The outputaaronhall wrote:I think you just built a parser that parses the output of the same parser it uses to parse that parsers output. It won't output the parent function, but it'll probably time travel or something.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
I was just trying to make my brain implode. I really don't know why you would ever use a function like that -- the variable wouldn't even exist in the scope you're calling the function from.neel_basu wrote:It would Use fopen() to open the File And fread() to read it So It Would Not Parse The outputaaronhall wrote:I think you just built a parser that parses the output of the same parser it uses to parse that parsers output. It won't output the parent function, but it'll probably time travel or something.