Re: [PHP] error handling and __LINE__

2001-11-27 Thread SafeV

Thanks, assert() is cool, but it still reports the filename and line 
number of the included file with the function in which the error 
occurred, not the script that called the functon with illegal arguments.
Or...???

Eg.:
index.php:
?
include_once(functions.php); 
// foo() is declared here
foo(123); 
// illegal argument
?

This will produce a message saying an error occurred in functions.php, 
but I want it to tell me that the error occurred in index.php, line 3.
Because if I call foo() many times in a script, it is difficult to find 
out which call that failed.

Is this impossible?

Papp Gyozo wrote:

 try, assert() instead of echo()ing error messages.
 
 assert('is_object($obj)');
 
 and write your error handler code or use mine :)
 or am i missing something?
 
 Papp Gyozo
 - [EMAIL PROTECTED]
 
 - Original Message - 
 From: SafeV [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, November 22, 2001 4:15 PM
 Subject: [PHP] error handling and __LINE__
 
 
 | Hi,
 | I wonder if there's a way to find the line number of the calling script 
 | from a function, like the error messages PHP generates. An example:
 | 
 | In an included file I have a function and want to do something similar to:
 | 
 | function foo($obj) {
 | if (!is_object($obj)) {
 | echo Error: supplied argument is not an object in ;
 | echo __FILE__ .  line  . __LINE__; 
 | }
 | ...
 | }
 | 
 | But __FILE__ and __LINE__ refers to the current file, ie. the file with 
 | the function in, and not the file where the function is called from.
 | The first one I can solve by using $SCRIPT_NAME, but what about the line 
 | number???
 | 
 | 
 | 
 | -- 
 | PHP General Mailing List (http://www.php.net/)
 | To unsubscribe, e-mail: [EMAIL PROTECTED]
 | For additional commands, e-mail: [EMAIL PROTECTED]
 | To contact the list administrators, e-mail: [EMAIL PROTECTED]
 | 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] error handling and __LINE__

2001-11-22 Thread SafeV

Hi,
I wonder if there's a way to find the line number of the calling script 
from a function, like the error messages PHP generates. An example:

In an included file I have a function and want to do something similar to:

function foo($obj) {
if (!is_object($obj)) {
echo Error: supplied argument is not an object in ;
echo __FILE__ .  line  . __LINE__;
}
...
}

But __FILE__ and __LINE__ refers to the current file, ie. the file with 
the function in, and not the file where the function is called from.
The first one I can solve by using $SCRIPT_NAME, but what about the line 
number???



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] error handling and __LINE__

2001-11-22 Thread Papp Gyozo

try, assert() instead of echo()ing error messages.

assert('is_object($obj)');

and write your error handler code or use mine :)
or am i missing something?

Papp Gyozo
- [EMAIL PROTECTED]

- Original Message - 
From: SafeV [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, November 22, 2001 4:15 PM
Subject: [PHP] error handling and __LINE__


| Hi,
| I wonder if there's a way to find the line number of the calling script 
| from a function, like the error messages PHP generates. An example:
| 
| In an included file I have a function and want to do something similar to:
| 
| function foo($obj) {
| if (!is_object($obj)) {
| echo Error: supplied argument is not an object in ;
| echo __FILE__ .  line  . __LINE__; 
| }
| ...
| }
| 
| But __FILE__ and __LINE__ refers to the current file, ie. the file with 
| the function in, and not the file where the function is called from.
| The first one I can solve by using $SCRIPT_NAME, but what about the line 
| number???
| 
| 
| 
| -- 
| PHP General Mailing List (http://www.php.net/)
| To unsubscribe, e-mail: [EMAIL PROTECTED]
| For additional commands, e-mail: [EMAIL PROTECTED]
| To contact the list administrators, e-mail: [EMAIL PROTECTED]
|