Mother Function of A local variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

The Ninja Space Goat wrote:what's the deal with this response?
:oops: To hug php While playing With it :lol:
You've said that in a few threads... what does that mean?? :?
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.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

I was joaking

:lol: Actually I learnt php While playing with it
And I love it
and so
If php is a female human being
:oops: i wanna get a hug from her.
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.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

OK But anybody knows te answer of my question ??
Please Reply.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

There's no such thing in php. You might write your own parser - but somehow I doubt that's what you want.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

OK Thanks I've got my Answer

My Question was
How to Get the a variable's mother function's name from a that variable name
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Weird question. I've not tried yet. Sounds interesting but not what's the use of doing this ?
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

dibyendrah wrote:what's the use of doing this ?
Playing
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

neel_basu wrote:
dibyendrah wrote:what's the use of doing this ?
Playing
I'm sure you could be more creative than this if your after "fun" activities :wink:
User avatar
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

Post by Christopher »

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
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.
(#10850)
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

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 )
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

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.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

aaronhall 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.
It would Use fopen() to open the File And fread() to read it So It Would Not Parse The output
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

php developers might know better. :?:
Why are you exploring this issue ? :lol:
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

neel_basu wrote:
aaronhall 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.
It would Use fopen() to open the File And fread() to read it So It Would Not Parse The output
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.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

I have decleared The Cause above
Post Reply