Define data members within constructor

Posted by bertsisterwanda on Stack Overflow See other posts from Stack Overflow or by bertsisterwanda
Published on 2010-04-29T15:31:23Z Indexed on 2010/04/29 15:37 UTC
Read the original article Hit count: 334

Filed under:
|
|
|
|

I have got this little snippet of code, I want to be able to define each array element as a new data member.

class Core_User
{
     protected $data_memebers = 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($data_memebers as $member){
           //protected new data member
        }

    }

© Stack Overflow or respective owner

Related posts about php

Related posts about oop