Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2015 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/69b42033d2e6e32e124d to your computer and use it in GitHub Desktop.
Save anonymous/69b42033d2e6e32e124d to your computer and use it in GitHub Desktop.
/*** 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