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

Mother Function of A local variable

Post by neel_basu »

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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Why would you like to know that?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

huh? :?
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 »

Weirdan wrote:Why would you like to know that?
:oops: To hug php While playing With it :lol:
If Somebody Have the answer Pls tell me
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Mother Function of A local variable

Post by Weirdan »

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
Like this:

Code: Select all

function someFunc() {
   $a = false;
}
echo containingFunctionOf('a'); // would echo 'someFunc'
?
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Re: Mother Function of A local variable

Post by neel_basu »

Weirdan wrote:

Code: Select all

function someFunc() {
   $a = false;
}
echo containingFunctionOf('a'); // would echo 'someFunc'
Ya Like This but is containingFunctionOf really a function in php
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Ya Like This but is containingFunctionOf really a function in php
considering that was a question, the answer is 'no'. I'm just speculating here to see if it could be implemented at all. What would this imaginary function return when used in the following snippet?:

Code: Select all

function someFunc() {
   $a = false;
}

function someOtherFunc() {
   $a = 'something';
}

echo containingFunctionOf('a'); // would it be 'someFunc'? or 'someOtherFunc'? maybe array('someFunc', 'someOtherFunc')?
Last edited by Weirdan on Wed Jan 03, 2007 1:34 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 »

Well Do You Know a function that can do this job
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Unless you have definitive answer to my previous question I'm not even sure if such a function could exist.
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 »

Weirdan wrote:
Ya Like This but is containingFunctionOf really a function in php
considering that was a question, the answer is 'no'. I'm just speculating here to see if it could be implemented at all. What would this imaginary function return when used in the following snippet?:

Code: Select all

function someFunc() {
   $a = false;
}

function someOtherFunc() {
   $a = 'something';
}

echo containingFunctionOf('a'); // would it be 'someFunc'? or 'someOtherFunc'? maybe array('someFunc', 'someOtherFunc')?
It would Return te function name
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

It would Return te function name
what function exactly? there are two functions defined, both have the $a variable in their local scope (in other words, two different variables named $a exists, one belonging to someFunc's scope and other belonging to someOtherFunc's scope).
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 »

The someOtherFunc()
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

and why not 'someFunc' then?
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 »

1st do That one Then The previous one. Cause i dont need Any True false variable's mother function
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

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?? :?
Post Reply