Line Error Php
Contents |
and Objects Namespaces Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Context options and parameters Supported Protocols and php trigger error Wrappers Security Introduction General considerations Installed as CGI binary Installed
Php Error Types
as an Apache module Session Security Filesystem Security Database Security Error Reporting Using Register Globals User
Php Error_get_last
Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads Using remote files Connection handling
How To Display Error Message In Php
Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line Specific Extensions Compression and Archive Extensions Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and Character Encoding php if( error) Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions Web Services Windows Only Extensions XML Manipulation Keyboard Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box debug_backtrace » « Examples PHP Manual Function Reference Affecting PHP's Behaviour Error Handling Change language: English Brazilian Portuguese Chinese (Simplified) French German Japanese Korean Romanian Russian Spanish Turkish Other Edit Report a Bug Error Handling Functions See Also See also syslog(). Table of Contentsdebug_backtrace — Generates a backtracedebug_print_backtrace — Prints a backtraceerror_clear_last — Clear the most recent errorerror_get_last — Get the last occurred errorerror_log — Send an erro
and Objects Namespaces Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and php custom error handler Classes Context options and parameters Supported Protocols and Wrappers error message in php form validation Security Introduction General considerations Installed as CGI binary Installed as an Apache module php error message Session Security Filesystem Security Database Security Error Reporting Using Register Globals User Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP http://php.net/manual/en/ref.errorfunc.php authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads Using remote files Connection handling Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line Specific Extensions Compression and http://php.net/manual/en/language.operators.errorcontrol.php Archive Extensions Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions Web Services Windows Only Extensions XML Manipulation Keyboard Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box Execution Operators » « Comparison Operators PHP Manual Language Reference Operators Change language: English Brazilian Portuguese Chinese (Simplified) French German Japane
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn http://stackoverflow.com/questions/185778/how-to-get-proper-line-number-when-using-trigger-error-in-php more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to get proper line number when using trigger_error in PHP? up vote 1 down vote favorite I am using trigger_error to "throw" errors in a php error custom class. My problem is that trigger_error prints out the line number where trigger_error was called. For example, given the following code: 01 doSubAction(); 05 } 06 07 function doSubAction() { 08 if(true) 09 trigger_error('Custom error', E_USER_WARNING); 10 } 11 } 12 13 $var = new Test(); 14 $var->doAction(); 15 ?> PHP will print out the following: Warning: Custom error in test.php on line 9 How error message in would you make PHP return the line where the doAction() function was called (the method called outside the class, ignoring all calls made internally) as follows? Warning: Custom error in test.php on line 14 Edit: Modified my example to be something a bit closer to what I'm trying to achieve. php error-handling share|improve this question edited Oct 9 '08 at 3:12 asked Oct 9 '08 at 2:58 Andrew Moore 63.4k22132154 add a comment| 5 Answers 5 active oldest votes up vote 2 down vote The best thing to do is set up an error handler that shows a full stack trace. Set up a custom error handler, and call debug_print_backtrace() in it. You will find this useful in general, as well in this specific circumstance. share|improve this answer answered Oct 9 '08 at 3:08 Jerub 25.3k105587 add a comment| Did you find this question interesting? Try our newsletter Sign up for our newsletter and get our top new questions delivered to your inbox (see an example). Subscribed! Success! Please click the link in the confirmation email to activate your subscription. up vote 0 down vote Two options, neither one are particularly palatable: Override Have test() provide __LINE__ in the arguments (eg. "test(__LINE__)", and give the argument to trigger_error). Set an error handler to print a custom error message. NOTE: This is horrifically ugly. :-) Set up