Hailwood Posted February 18, 2010 Share Posted February 18, 2010 Hi there, Is there any way in php to ask it to output the filename and line that a particular variable is defined? eg echo whereIs($date); would output test.php :391 or something similar, this is because i have a whole pile of includes (mostly from a framework) and i need to find out where a particular var is coming from! Quote Link to comment Share on other sites More sharing options...
sader Posted February 18, 2010 Share Posted February 18, 2010 there are some "magic constants": __LINE__ __FILE__ __FUNCTION__ __CLASS__ __METHOD__ it's not exactly what u are asking but i guess to do what u want could be done like this(in my opinion it looks a bit dump ) $var_defined_at = (__LINE__+1).":".__FILE__ ; $var = "value"; echo "\$var defined at:$var_defined_at"; Quote Link to comment Share on other sites More sharing options...
Hailwood Posted February 18, 2010 Author Share Posted February 18, 2010 Yeah cheers, i already know those, im talking about a function i could call anywhere on a variable and it will return it... Quote Link to comment Share on other sites More sharing options...
trq Posted February 18, 2010 Share Posted February 18, 2010 Short answer is no. You could likely write a program to find it, or get a decent editor. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.