why does it shows undefined variables. Undefined variable: classRooms. Why should I use var in class properties instead of only using $ in php.
class School {
var $teachersCount = 10;
var $classRooms =20;
function teachingHours(){
$teacherHours = array();
$teacherHours = $this->classRooms / $this->teachersCount;
foreach ($teacherHours as $key => $hours) {
$teacherHours = $teacherHours -$key;
echo $teacherHours.''.$key;
}
}
}
Instantiating the School class
$school = new School();
echo $school-> classRooms;
echo"<br>";
echo $school -> teachersCount;
echo"<br>";
$school-> teachingHours();