I just wonder what is the best way to assign default value in PHP Class.
Example:
The PHP constructor __construct() method is the first method will be read whenver the class is called. So here's some code:
class A{
private $x;
public function __construct(){
//Var x iniated in constructor method
$this->x = "some values";
}
}
Example above I put x variable to "some values" in constructor method.
And I tried this (below codes) too and it works the same.
class A{
private $x = "some values";
public function __construct(){
//Var x initiated out of constructor method
}
}
My question is, which one is the best practice?