Welcome Guest, Not a member yet? Register   Sign In
Problem with returned from the database in class
#4

You were asking why the object properties are not public.
Well, maybe because you declared them as protected in the User_lib class yourself?
PHP Code:
class User_lib {
protected 
$customer_id;
protected 
$email;
protected 
$firstname;
protected 
$date_added;


If properties are public, you can set them anywhere in your application like this:
PHP Code:
$this->User_lib->email '[email protected]'

If properties are private or protected, you need a __set() method inside your object to change the value. Like this:
PHP Code:
   public function __set($name$value)
 
   {
 
       $this->$name $value;
 
   

This is a so-called magic method. It will be automatically called when you try to change the value of a non-public property.
Reply


Messages In This Thread
RE: Problem with returned from the database in class - by Wouter60 - 02-27-2017, 12:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB