In PHP 4 constructors had the same name as the class itself.
<?php
class banana_v4 {
function banana_v4() {
echo "peel..peel..";
echo "\n<br />\n";
}
function eat() {
echo "chewy..chewy..";
echo "\n<br />\n";
}
}
$b = new banana_v4();
$b->eat();
?>
Output
In PHP 5 constructors are unified, under the name __construct().
<?php
class banana_v5 {
function __construct() {
echo "peel..peel..";
echo "\n<br />\n";
}
function eat() {
echo "chewy..chewy..";
echo "\n<br />\n";
}
}
$b = new banana_v5();
$b->eat();
?>
Output
peel..peel..
chewy..chewy..