Ok I've narrowed down my problem but can't come up with a fix.
I want the first class to be able to reference variables from the second class.
class TheFirstClass{
public function __construct(){
include 'SecondClass.php';
$SecondClass = new SecondClass;
echo($SecondClass->hour);
}
}
//in it's own file
class TheSecondClass{
public $second;
public $minute = 60;
public $hour;
public $day;
function __construct(){
$second = 1;
$minute = ($second * 60);
$hour = ($minute * 60);
$day = ($hour * 24);
}
}
But in this situation, only the "minute" is able to be accessed from the other class. If I were to remove the "= 60", then the minute would return nothing along with the rest of the variables.
The variables within the constructor are calculated correctly, but they do not affect the variables of the same name higher in the scope. Why, and what would be the correct way to structure the code instead?