In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Joshua E Minnie) wrote:

> What I am trying to do is create an error message within in a string that
> whenever each function fails it echos this particular string out with it's
> pertinent information.
> i.e.
> <?
> $error_string = "Warning: unable to complete query in ".__FUNCTION__."name
> in ".__FILE__;
> function some_funct($var) {
>   global $error_string;
>   //doing something
>   //error detected
>   echo $error_string;
> }
> ?>
> Does this sounds feasible or is there another way to generate a dynamic
> error message without giving the user to much information about the error if
> it occurs?

For this purpose, substitute __LINE__ for __FUNCTION__, and you're in 
business.  A line number is less revealing to an end-user anyway than a 
function name (you don't want "Error in function 'log_private_user_info()'" 
showing up).  But it's more specific abouty pinpointing the place (or last 
possible place, anyway) that script went wrong.  In a functions several 
hundred lines long and with control structures defining many possible paths 
through it, knowing only that the function had an error *somewhere 
(unknown)* isn't very helpful.

A step up would be to use the error handling functions instead 
<>.  Then you can customize which errors get 
reported to the user, under what circumstances, how, whether to forward the 
reports to you as well, plus the opportunity to know the context (set 
variables and their values) in which the error occured.


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to