/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php class errors{ private $_data=''; private $_handlingStarted=0; private $_error=0; function __construct() { $this->_data='<script type="text/javascript"><!--'."\n"; $this->start(); return true; } function started(){ return($this->_handlingStarted); } function start(){ $this->_handlingStarted=1; } function isError(){ return $this->_error; } function appendJSError($text){ if(!$this->started()) return ERRORS_STREAM_NSET; $this->_error=1; $this->_data.='alert("'.$text.'");'."\n"; } function redirect($url){ if(!$this->started()) return ERRORS_STREAM_NSET; $this->_data.='window.location.href=\''.$url.'\';'."\n"; } function stopHandling() { $this->_data.='--></script>'."\n"; } function outputData() { if(!$this->started()) return ERRORS_STREAM_NSET; $this->stopHandling(); return $this->_data; } } ?>