Hello, I have two classes. Looking to be able to grab a variable that is within a global object of a class.
Class Order {
public $number = "1234";
}
Class Business {
public $order;
function __construct() {
global $order;
$order = new Order();
}
}
$b = new Business();
echo $b->order->number;
In the case above nothing is displayed not even an error. Ive tried different ways of accessing the variable but have only been successful by making a helper function to make a call like the following:
echo $b->getOrder()->number;
or
$temp = $b->order;
echo $temp->number;
Both give the required result of "1234" however I am sure there is a way to do it in 1 line without having to make a getter function.
Any help would be greatly appreciated.