Help - Search - Members - Calendar
Full Version: trigger_error issue (PHP)
Invision Power Services > Community Forums > Community Web Design and Coding
Luke
Let's say I have this (this is a VERY simple example. I've included line numbers):

File1.php

CODE
1: function myfunction()
2: {
3:      trigger_error("blah error'", E_USER_WARNING);
4: }


File2.php

CODE
1: require_once("File1.php");
2: myfunction();


Now trigger error returns the error is in File1.php and on line 3. The function called is actually in File2.php and on line 2. Is there anyway to make trigger_error output information where the function was called and not on trigger_error?
Michael_C
That behaviour is correct because that is where the error was triggered.
Luke
I know but im asking if there is a way getlost.gif .

Telling me it triggered in the function doesnt help, telling me where the function was called helps.
Michael_C
If you really wanted to do that you could add an optional parameter to the function and pass a unique code/number etc. from each place you call it then you can see where its coming from.
CODE
function myfunction($from = '')
{
    trigger_error('blah error, called from: <em>' . $from . '</em>', E_USER_WARNING);
}

CODE
require_once("File1.php");
myfunction('index.php:init');
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.