473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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
3 8819

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Abrahams | last post by:
Is there any way to determine the file and line number (if any) of a method's invocation from within its body? Many Thanks in advance, Dave -- David Abrahams Boost Consulting...
2
by: Jim Cobban | last post by:
I am using Xerces to read an XML file and load it into a DOM so I can update it and subsequently serialize the updated DOM. The problem I have is that as I traverse the DOM I would like to inform...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
5
by: BlueFox | last post by:
Hi : When i display the DataBase in System.Windows.Forms. DataGrid ,i want to display the line number of ever line .How can i do it ? Any help may be Good .
4
by: John Galt | last post by:
I have a stacktrace that gives the line number of the offending code, but for the life of me can't seem to find a display of the line number in the Visual Studio.Net code editor. I'm sure I've seen...
6
by: Phil Jollans | last post by:
Hi, I have an error dialog which shows the stack trace, usually without line numbers in the release version. To try to diagnose a particular problem, I have provided a user with a debug version...
5
by: Mark Kamoski | last post by:
Hi Everyone-- How can one get the line number of where an error was thrown and/or caught? For example, note the following, for use at any given point in a piece of code: ....to get the...
5
by: Bob Day | last post by:
VS 2003, vb.net... Is there a way to determine the line number currently executing in your code, so you can log this line number information (e.g. via trace)? Thanks! Bob Day
1
by: pukya78 | last post by:
Hi, I am trying to get the current file and the line number which is getting executed. I used: MessageBox.Show(New StackTrace(New StackFrame(True)).GetFrame(0).GetFileLineNumber) which gives me...
1
by: Hari Sekhon | last post by:
Hi, I'm wondering if anyone can please help me on figuring out a better way of doing an excepthook. I have a script which is using an excepthook to catch any uncaught exceptions - there usually...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.