My code:
class Address{ public var $Street; } class Employee{ public var $ID: public var $Name: public var $Address; } $myEmployee = new Employee(); $myEmployee->Address = new Address();
How do I access the the street now?
$street = $myEmployee->$Address->Street; $street = $myEmployee->Address->Street;
Both give me warnings in Eclipse. I was thinking of:
$street = $myEmployee['Address']->Street;
Is this correct?
As has been said, your suggestion to use:
is perfectly valid. However, there are a few errors in your code which might have caused the problems. Firstly, public member variables are either declared like this:
or this (deprecated):
Your combination of the two is not valid PHP code.
Also, you have two colons (:) at line endings, which should be semicolons (;).
Hope that helps!