Possible Duplicate:
Benefits of using a constructor?
hello coders. I am newbie to OOP in php. I am doing a project in objects and class. where
most of time I face a line
public function __construct(){
}
I can’t understand this. Why its used and what is its value. Can some one tell me about it. I went to the php.net site but my doubt not cleared.
The __construct allows arguments to be passed to an object on initalisation, without you would do something like this:
But if you have this:
You can just do:
Another possible use for the constructor (though not good practice):