I am studying PHP, and a problem arises (Notice: Undefined property) when I do the HERENCIAS exercise of the class.
More specifically, he says:
"Notice: Undefined property: double-inherited :: $ muninterno in C: \ xampp \ htdocs \ project_php_seas \ 418-herencias.php on line 25 ".
If someone can help me, I would be grateful, since my teachers are cows.
I put the code in PHP and then the result:
************** PHP code: *************
<?php
class doble {
var $mult=2;
public $numinterno;
public function multxnum() {
return $this->mult*$this->numinterno;
}
public function divxnum () {
return $this->numinterno/$this->mult;
}
}
class dobleheredada extends doble {
public function triple() {
return ($this->multxnum()*$this->muninterno);
}
}
$miobjeto= new doble();
$miobjeto->numinterno=3;
$eldoble=$miobjeto->multxnum();
echo "El valor doble del parámetro es: $eldoble";
echo "<br>";
$lamitad=$miobjeto->divxnum();
echo "El valor mitad del parámetro es: $lamitad";
$objeto3=new dobleheredada();
$objeto3->numinterno=3;
$eltriple=$objeto3->triple();
echo "<br>";
echo "El doble del cuadrado del parámetro es: ".$objeto3->triple();
echo "El doble del cuadrado del parámetro es: $eltriple";
?>
************* Script Result: **********
The double value of the parameter is: 6
The half value of the parameter is: 1.5
Notice: Undefined property: double-inherited :: $ muninterno in C: \ xampp \ htdocs \ project_php_seas \ 418-herencias.php on line 25
Notice: Undefined property: double-inherited :: $ muninterno in C: \ xampp \ htdocs \ project_php_seas \ 418-herencias.php on line 25 El double the square of the parameter is: 0 Double the square of the parameter is: 0 "