Hallo iedereen,
Ik ben bezig met "OOP" te leren.
Nu heb ik een probleempje:
dit is mijn code:
<?php
ini_set('display_errors', 1);
class tree{
public $leafs;
protected $twigs;
protected $roots;
protected $tree_trunk;
public $seeds;
}
tree::leafs;
class seasons extends tree{
/**
public function __construct(){
$this->leafs = $leafs;
}
**/
public static function Winter(){
echo '<br/>Winter brings the cold and so there are no leafs.';
}
public static function Spring(){
echo '<br/>Spring is here and the leafs are growing.';
$this->leafs = 'green';
echo 'The leafs have also turned : ' . $leafs;
}
public static function Summer(){
echo '<br/>Summer brings in the heat.';
$leafs .= 'green';
}
public static function Autumn(){
echo '<br/>Autumn is here and the leafs fall down to the ground.';
$leafs .= 'brown';
echo 'The leafs have also turned : ' . $leafs;
}
}
seasons::Winter();
seasons::Spring();
seasons::Summer();
seasons::Autumn();
?>
maar als ik hem nu in de browser bekijk dan is de output :
Fatal error: Undefined class constant 'leafs' in D:\xampplite\htdocs\thuis\test\tree.php on line 14
iemand een oplossing, en of ziet het probleem?
bedankt.
1.075 views