Re: Accessing $php_errmsg give an error ...
| From: | Ernest E Vogelsinger | Date: | Wed, 29 Jan 2003 11:04:47 +0000 |
| Subject: | Re: Accessing $php_errmsg give an error ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-133478@lists.php.net to get a copy of this message | ||
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/