Accessing inherited class variables in PHP

I have two classes. Looking to be able to grab a variable that is within a global object of a class.\[code\]Class Order { public $number = "1234";}Class Business { public $order; function __construct() { global $order; $order = new Order(); }}$b = new Business();echo $b->order->number;\[/code\]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:\[code\]echo $b->getOrder()->number;\[/code\]or \[code\]$temp = $b->order;echo $temp->number;\[/code\]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.
 
Back
Top