/* * vytvoril patrik bona - head * posledna zmena: 6. 10. 2003 * * no tuto triedu som si nedavno vytvoril na kontrolu chyb * od uzivatela ( z formularov) * pouzitie: * add("nastala taka a taka chyba"); * } * ... * if($err->wasError()) { // zistime ci bola pridana chyba * $err->flush(); // vypiseme chyby, ktore nastali * } else { * echo "OK vsetko prebehlo bez chyb ;-)"; * } * ?> */ class error { var $error; var $index; var $i; function add($err) { $this->error[$this->index] = $err; $this->index++; } function wasError() { if($this->index > 0) { return true; } return false; } function flush() { while($this->i < $this->index) { echo $this->error[$this->i]; echo "
\n"; $this->i++; } $this->del(); } function del() { $this->error = array(); $this->index = 0; $this->i = 0; } function error() { $this->error = array(); $this->index = 0; $this->i = 0; } }