Link to home
Start Free TrialLog in
Avatar of wildzero
wildzero

asked on

PHP oop goodness :-)

Hi there,

Just getting my hands on some PHP5 oop goodness...
now just writing up a class that will handle a user.

now I can do
class user
{
      
  private $id   = -1;
  private $fname = '';
  ......

then do a function load_user($id)
select user from database and use mysql_fetch_assoc
like
$user_data = mysql_fetch_assoc($result);
Foreach ($user_data AS $key->$var)
  $this->$key = $var;

however, what happens if I don't want to declear all those private vars at the start of the class...
can I do
Foreach ($user_data AS $key->$var)
  private($this->$key = $var);
or some other way of telling PHP5 that this new var is to be private. Because by default it's public.

Just trying to make it as clean cut and readable as possible....

ASKER CERTIFIED SOLUTION
Avatar of dragoncc
dragoncc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial