On Sat, Dec 01, 2001 at 12:15:37AM +0100, Jeroen Olthof wrote:
> let's say I have made some objects
> $content = new Content();
>
> and in object content a new object is created
> $person = new Person("Jeroen");
>
> Person holds a var age
>
> Now I want to do something like this in a normal PHP script
>
> echo $content->getPerson("Jeroen")->getAge();
> or since PHP doesn't use private / prublic / etc..
> echo $content->getPerson("Jeroen")->age;
>
> the point is , getPerson("Jeroen") returns an object. this object contains
> the function getAge() which return the var age
> but somehow this constuction isn't possible !!!! ????? Why !!!!
> ....... or is it but is there a strange syntax ????
As someone else already mentioned, this isn't in PHP yet. But it's coming.
In the mean time, you have a couple options. If you only have one Person
inside a Content, you can simply say $content->person->age; If you have
more than one, they could be arranged in an array, so it becomes
$content->person['Jeroen']->age;
Another option is to define a method in Content which returns $person->age.
Matt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]