I have to agree, your example works fine for me. For testing I used the
latest stable Release of server2go with PHP 5.2.10.

Or do you want to use something like that:

class o
{
        protected $arr = array('a'=>0);
        function o($n){$this->arr['a'] = $n;}
        function getA(){return $this->arr['a'];}
}

$o = array( new o(1), new o(2) );


if ( end($o)->getA() > 1 ) {  
echo "yeah";
}

Which works fine as well ... 

Regards,
jan

-----Original Message-----
From: Tom Worster [mailto:f...@thefsb.org] 
Sent: Saturday, September 12, 2009 1:31 AM
To: PHP General List
Subject: [PHP] get an object property

if i have an expression that evaluates to an object, the return value from a
function, say, and i only want the value of one of the objects properties,
is there a tidy way to get it without setting another variable?

to illustrate, here's something that doesn't work, but it would be
convenient if it did:

$o = array( (object) array('a'=>1), (object) array('a'=>2) );

if ( end($o)->a > 1 ) {  // can't use -> like this!
...
}




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Eingehende eMail ist virenfrei.
Von AVG überprüft - www.avg.de 
Version: 8.5.409 / Virendatenbank: 270.13.71/2336 - Ausgabedatum: 09/11/09
09:15:00 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to