id = $Id; $this->name = $Name; $this->image_url = $Image_url; $this->description = $Description; $this->price = $Price; } /* get_details() * Will return an array of data that pertains to the Product. This can be used when * we need to display products on a webpage. We can use this when passing parameters * to the template. */ public function get_details() { return array( 'product_id' => $this->id, 'product name' => $this->name, 'product_image_url' => $this->image_url, 'product_description' => $this->description, 'product_price' => $this->price ); } /* * __get($var); * Lets us read class member variables without writing individual getter functions. * We can have access to the variables as if they were public, but we have no write access * to them. Also, we can restrict which variables can be accesed like this with the allowed_vars array below. */ public function __get($var) { $allowed_vars = array('id','name','image_url','description','price'); if (in_array($var, $allowed_vars)) return $this->$var; else return false; } } ?>