php - Define data members within constructor -
i have got little snippet of code, want able define each array element new data member.
class core_user { protected $data_members = array( 'id' => '%d', 'email' => '"%s"', 'password' => '"%s"', 'title' => '"%s"', 'first_name' => '"%s"', 'last_name' => '"%s"', 'time_added' => '%d' , 'time_modified' => '%d' , ); function __construct($id = 0, $data = null) { foreach($this->data_members $member){ //protected new data member } }
//protected new data member
you won't able create non-public property @ runtime. if protected paramount, can declare protected array or object , insert key/values in constructor
Comments
Post a Comment