-
-
Save anonymous/69b42033d2e6e32e124d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** It is a small sample of my codes. | |
/* I have some `array()` that I need to them in all methods of this class. | |
/* So, instead of re-writing those array in each method, I wrote them in the `__construct($security)` just for one time. | |
/* It should be noted, in reality there is more than 50 `array()`. | |
class myclass1 | |
{ | |
public $voteup; | |
public $votedown; | |
public function __construct($security) | |
{ | |
$this->voteup = array('' => "", | |
'1' => "style='color: #f90'", | |
'-1' => ""); | |
$this->votedown = array('' => "", | |
'1' => "", | |
'-1' => "style='color: #f90'"); | |
} | |
public function one() | |
{ | |
// I need to both `$this->voteup` and `$this->votedown` in here | |
} | |
public function two() | |
{ | |
// I need to both `$this->voteup` and `$this->votedown` in here | |
} | |
} | |
class myclass2 | |
{ | |
public $voteup; | |
public $votedown; | |
public function __construct($security) | |
{ | |
$this->voteup = array('' => "", | |
'1' => "style='color: #f90'", | |
'-1' => ""); | |
$this->votedown = array('' => "", | |
'1' => "", | |
'-1' => "style='color: #f90'"); | |
} | |
public function one() | |
{ | |
// I need to both `$this->voteup` and `$this->votedown` in here | |
} | |
public function two() | |
{ | |
// I need to both `$this->voteup` and `$this->votedown` in here | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment