By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,746 Members | 1,924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,746 IT Pros & Developers. It's quick & easy.

Determine the line number that called a function.

P: n/a
Zim
Greetings,

I have an all purpose variable dumper that uses Var_Dump to show me
data structures.

I have an application wide function that I simply call to dump a
structure:

vardump($var);

function vardump ($vars, $details = null) {

if ($vars == 'dump') {
if (isset($GLOBALS['vardump']) ) {

Var_Dump::display($GLOBALS['vardump'],'GLOBALS',VAR_DUMP_DISPLAY_MODE_HTML_TABLE);
}
}
if ( isset($details) ) {
$GLOBALS['vardump'][$details][] = $vars;
} else {
$GLOBALS['vardump'][] = $vars;
}

}
The function can also accept a second argument that lets dumps
information about who/what/where the variable is being dumped from.

Now, sometimes I'm dumping alot so I would like to know where exactly
the dump came from, like this:

vardump($rows, basename(__FILE__) .' <br> '. __LINE__ );

Now, I'd like to keep the vardump() call as clean as possible. Is there
anyway for the function vardump to know the __FILE__ and __LINE__
without being told in an argument?

Many thanks!

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Zim" <27*******@sneakemail.com> wrote in message
news:cc********@odak26.prod.google.com...
Greetings,
<snip> Now, sometimes I'm dumping alot so I would like to know where exactly
the dump came from, like this:

vardump($rows, basename(__FILE__) .' <br> '. __LINE__ );

Now, I'd like to keep the vardump() call as clean as possible. Is there
anyway for the function vardump to know the __FILE__ and __LINE__
without being told in an argument?


You, Sir, seek a stack trace. Such a thing does not exist. Google records
the following from 2002 in php.general:

"There is no native PHP function for getting a stack trace. This has been
discussed many times on the PHP-DEV mailing list. It has always been
discarded due to an unacceptable overhead that would be introduced into the
parsing process."

Sorry it's not better news.

Garp
Jul 17 '05 #2

P: n/a
"Garp" <ga***@no7.blueyonder.co.uk> emerged reluctantly from the
curtain and staggered drunkenly up to the mic. In a cracked and
slurred voice he muttered:
You, Sir, seek a stack trace. Such a thing does not exist.
Google records the following from 2002 in php.general:


Oh rrrreeeeallly?

*COUGH* http://uk.php.net/debug_backtrace *COUGH*

--
Phil Roberts | Without me its just aweso. | http://www.flatnet.net/

"Mankind differs from the animals only by a little,
and most people throw that away."
- Confucious
Jul 17 '05 #3

P: n/a

"Phil Roberts" <ph**********@googlemail.com> wrote in message
news:Xn*************************@216.196.97.132...
"Garp" <ga***@no7.blueyonder.co.uk> emerged reluctantly from the
curtain and staggered drunkenly up to the mic. In a cracked and
slurred voice he muttered:
You, Sir, seek a stack trace. Such a thing does not exist.
Google records the following from 2002 in php.general:


Oh rrrreeeeallly?

*COUGH* http://uk.php.net/debug_backtrace *COUGH*


God, when did that appear! >hugz< Ah, 4.3.0........ I predate that. Yay!

Garp


Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.