http://www.killerphp.com/tutorials/object-oriented-php/php-objects-page-3.php
Step 13:
Constructors
All objects can have a special built-in method called a 'constructor'. Constructors allow you to initialise your object's properties (translation: give your properties values,) when you instantiate (create) an object.
Note: If you create a __construct() function (it is your choice,) PHP will automatically call the __construct() method/function when you create an object from your class.
The 'construct' method starts with two underscores (__) and the word 'construct'.
<?php
class person {
var $name;
function __construct($persons_name) {
$this->name = $persons_name;
}
function set_name($new_name) {
$this->name = $new_name;
}
function get_name() {
return $this->name;
}
}
?>
My Note:
Sir/Madam, I didn't get the use of method __construct, but no problem with other methods there.
If possible, a sample of View Page that uses the __construct will be more clear.
Thank you for your response!