Ok, I’m here because I got utterly sick of stackoverflow downvotes. Let’s see how this goes.
Here’s the classes code I’m trying to understand. I hope this is clear enough.
class My_Looping_Class {
public function __construct() {
for($y=0;$y<=10;$y++) {
$this->do_loop();
}
}
private function do_loop() {
//in this loop the value of $x in My_Var_Class gets incremented each loop but I'm not exactly
//sure how to call it.
}
}
class My_Var_Class {
public $x = 0;
}
class My_Looping_Class_Copy extends My_Looping_Class {
function show_x() {
//Show the $x in My_Var_Class each time it gets incremented.
echo $x.'<br>';
}
// Here I need to be able to read and echo the value of x in My_Var_Class each time it
//changes but again, I'm unsure of how to call it.
}
new My_Looping_Class_Copy();