Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Code:
Selected Language:
Show Linenumbers:
Short link for Twitter:
HTML:

HTML view:

Copy Source | Copy HTML
  1. class error_class{
  2.     private $err=false;
  3.  
  4.     public function set_err($msg=''){
  5.         $this->err=$msg;
  6.     }
  7.  
  8.     public function clear_err(){
  9.         $this->err=false;
  10.     }
  11.  
  12.     public function is_err(){
  13.         return $this->err;
  14.     }
  15. }
  16.  
  17. class test_class{
  18.     public $err;
  19.  
  20.     public function __construct(){
  21.         $this->err = new error_class();
  22.     }
  23.  
  24.     public function some_method(){
  25.         $this->err->clear_err();
  26.         if(some_err){
  27.             $this->err->set_err($msg='Some error appear.');
  28.             return false;
  29.         }
  30.         return true;
  31.     }
  32.  
  33.     public function complex_method(){
  34.         $this->err->clear_err();
  35.         $this->some_method();
  36.         if($this->err->is_err()!==false){
  37.             return false;
  38.         }
  39.         return true;
  40.     }
  41. }
  42.  
  43. define('some_err',true);
  44. $test_instance = new test_class;
  45. $test_instance->complex_method();
  46. if($test_instance->err->is_err()!==false){
  47.     die($test_instance->err->is_err());
  48. }
  49. die('No error appear.');
  50.  
  51.  




Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2012