473,698 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::displ ay($GLOBALS['vardump'],'GLOBALS',VAR_ DUMP_DISPLAY_MO DE_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 8832

"Zim" <27*******@snea kemail.com> wrote in message
news:cc******** @odak26.prod.go ogle.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.blue yonder.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**********@g ooglemail.com> wrote in message
news:Xn******** *************** **@216.196.97.1 32...
"Garp" <ga***@no7.blue yonder.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
2989
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 http://www.boost-consulting.com
2
2856
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 the user of exceptional conditions in the file. However I cannot find any way while doing a DOM traversal to determine the line number that a particular Node occurs on, except to count all of the new-line characters which occur in Text Nodes. ...
11
21922
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 C# equivalent. Any ideas? -- ----------------------------------- Ken Varn Senior Software Engineer Diebold Inc. varnk@diebold.com
5
11454
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
1535
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 it in there before, but it seems to have disappeared. Does anyone know how to get this info?
6
2802
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 of my program, and now line numbers do appear. However, there is no line number at the top level in the stack, as shown below:
5
1946
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 current Assembly's name, one can use this... System.Reflection.Assembly.GetExecutingAssembly().GetName().Name
5
6100
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
1867
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 the line number. Later on, I was trying to write a generalized routine, so that I can log the file name and the method.
1
1814
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 aren't any except when I am messing with the code, like right now :-) The problem is that the excepthook gives the line of the topmost called function rather that the actual line that generated the error the way you get it with a normal...
0
9166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6525
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.