-
Code's Tags
-
Your Codes
-
Reffers
-
Linked Codes
|
Code:
Short link for Twitter:
HTML:
HTML view:
Copy Source | Copy HTML- class error_class{
- private $err=false;
-
- public function set_err($msg=''){
- $this->err=$msg;
- }
-
- public function clear_err(){
- $this->err=false;
- }
-
- public function is_err(){
- return $this->err;
- }
- }
-
- class test_class{
- public $err;
-
- public function __construct(){
- $this->err = new error_class();
- }
-
- public function some_method(){
- $this->err->clear_err();
- if(some_err){
- $this->err->set_err($msg='Some error appear.');
- return false;
- }
- return true;
- }
-
- public function complex_method(){
- $this->err->clear_err();
- $this->some_method();
- if($this->err->is_err()!==false){
- return false;
- }
- return true;
- }
- }
-
- define('some_err',true);
- $test_instance = new test_class;
- $test_instance->complex_method();
- if($test_instance->err->is_err()!==false){
- die($test_instance->err->is_err());
- }
- die('No error appear.');
-
-
|