467,104 Members | 1,025 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

Determine the line number that called a function.

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
  • viewed: 8587
Share:
3 Replies

"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
"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

"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.

Similar topics

2 posts views Thread by David Abrahams | last post: by
6 posts views Thread by Phil Jollans | last post: by
5 posts views Thread by Bob Day | last post: by
1 post views Thread by pukya78@gmail.com | last post: by
1 post views Thread by Hari Sekhon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.