[PHP] Accessing $php_errmsg give an error ...

2003-01-29 Thread Jean-Christian Imbeault
I am trying to access the last error message using the superglobal 
$php_errmsg. But trying to acess that var gives a not defined error ...

Running this script gives me:

?php
ini_set(track_errors, true);
error_reporting (E_ALL);

$a = $php_errmsg;
die;
?

Notice: Undefined variable: php_errmsg in err.php on line 5

What am I doing wrong?

Thanks,

Jc


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Accessing $php_errmsg give an error ...

2003-01-29 Thread Ernest E Vogelsinger
At 11:28 29.01.2003, Jean-Christian Imbeault said:
[snip]
I am trying to access the last error message using the superglobal 
$php_errmsg. But trying to acess that var gives a not defined error ...

Running this script gives me:

?php
ini_set(track_errors, true);
error_reporting (E_ALL);

$a = $php_errmsg;
die;
?

Notice: Undefined variable: php_errmsg in err.php on line 5
[snip] 

$php_errmsg is NOT a superglobal it's simply global so you need to
declare it within a function.

$php_errormsg is not set by default (warning prone) and will be overwritten
immediately by the next error or warning. What you should do is something
like this:

global $php_errormsg;
$php_errormsg = null;
@run_your_script();
$err = $php_errormsg;
if ($err) ...

hth,


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php