Muddy_Funster Posted January 3, 2013 Share Posted January 3, 2013 Have a look at this little sample I made up for you. It covers one way (my preffered way) of getting info out of the class: <?php class sample { public $errors; public function __construct(){ $this->loadSampleErrors(); } private function loadSampleErrors(){ $this->errors[] = array('errorInfo'=>'Form Fill Error', 'userMsg'=>"You forgot to enter your username!"); $this->errors[] = array('errorInfo'=>"Connection to server failed", 'userMsg'=>"A connection to the database server could not be established!"); $this->errors[] = array('errorInfo'=>"Database Not Found", 'userMsg'=>"Unable to locate the selected database!"); } public function pushErrorData(){ return $this->errors; } } $sample = new sample(); //do some stuff //.... //now check for errors: if(!empty($sample->errors)){ //got errors? best show them to the user then... echo "The Following Errors Were Encounterd :-<br /><br />"; $errorList = $sample->pushErrorData(); foreach($errorList as $error){ echo "an internal error of type <span style=\"font-weight:bold;\"> \"{$error['errorInfo']}\"</span> has been generated with the message :- {$error['userMsg']}"; echo"<br />----------------------------------------------<br />"; } } ?> you can run this script as is and see the output yourself. Quote Link to comment https://forums.phpfreaks.com/topic/272543-php-error-messaging/page/2/#findComment-1402967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.