I am learning how to use php OOP and use classes. I am doing exactly as the tutorial says and when they do the same they get an output and my screen is blank with no errors what so ever. All of these files are in the same folder also.
Here is the code:
index.php:
<?php
require 'Bird.php';
require 'Pigeon.php';
require 'Penguin.php';
$penguin = new Penguin(false, 2);
$penguin->foo();
?>
Bird.php:
<?php
//public
//protected
//private
class Bird {
protected $canFly;
protected $legCount;
public function __contruct($canFly, $legCount) {
$this->canFly = $canFly;
$this->legCount = $legCount;
}
public function canFlies() {
return $this->canFly;
}
public function getLegCount() {
return $this->legCount;
}
}
?>
Pigeon.php:
<?php
class Pigeon extends Bird {
}
?>
Penguin.php:
<?php
class Penguin extends Bird {
public function foo() {
echo $this->legCount;
}
}
?>
error_reporting(E_ALL); ini_set('display_errors', 1);
– Michael Berkowski Dec 7 '15 at 17:19__contruct
should be__construct
– Michael Berkowski Dec 7 '15 at 17:19__contruct
!==__construct
– Mark Baker Dec 7 '15 at 17:19