473,738 Members | 8,848 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 8837

"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
2993
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
2862
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
21929
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
11458
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
2805
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
1950
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
6102
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
1870
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
1816
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
8969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9263
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
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
6751
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
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
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
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
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.