best practice for initializing class members in php
- by rgvcorley
I have lots of code like this in my constructors:-
function __construct($params) {
$this->property = isset($params['property']) ? $params['property'] : default_val;
}
Is it better to do this rather than specify the default value in the property definition? i.e. public $property = default_val? Sometimes there is logic for the default…