Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Comments for: kris_hadlock20080215

Message # 1510467:
Date: 02/16/08 06:06
By: Daniel
Subject: function __construct()

Using PHP5 is great if you use OOP in the right way. So it's better to create a __contruct function to replace

public function Product() {}

like this:

function __construct($name, $price, $photo, $description) {
$this->name = $name;
$this->price = $price;
$this->photo = $photo;
$this->description = $description;
}

then in the child class you can use parent:: to take parent __construct and extend it:

function __construct($name, $price, $photo, $description, $model) {
parent::__construct($name, $price, $photo, $description);
$this->model = $model;
}

Cheers
Daniel

Previous Message | Next Message


Comments:
function __construct()Daniel02/16/08 06:06
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.