Hello Curt,
From http://us2.php.net/manual/en/language.operators.assignment.php
"The value of an assignment expression is the value assigned.
That is, the value of "$a = 3" is 3."
I take this to mean that ($foo->a = 'bar') will always return 'bar'
and that is a core feature of the language. Remember that $foo->a is
the left hand operand, and is only receiving the value. It is the =
operator that returns the value of the expression.
It may also be worth noting that the Associativity of the `=` operator
is "Right".
--
Best regards,
Jason mailto:[EMAIL PROTECTED]
Tuesday, July 20, 2004, 12:26:46 AM, you wrote:
CZ> Given the class definition:
CZ> <?php
CZ> class Caller {
CZ> private $x = array('a' => false);
CZ> function __set($name, $value) {
CZ> echo "setting\n";
CZ> $this->x[$name] = 'foo'; // intentially ignore value
CZ> }
CZ> function __get($name) {
CZ> echo "getting\n";
CZ> return $this->x[$name];
CZ> }
CZ> }
CZ> $foo = new Caller();
$b = $foo->>a = 'bar';
CZ> echo "b is " . $b . "\n";
CZ> /* output:
CZ> setting
CZ> b is bar
CZ> */
?>>
CZ> I sort of expected both __set and __get to be called. Is it
CZ> concievable to have them both called?
CZ> The other alternative If possible, is allowing a return value
CZ> from __set() and using that value for the rest of the expression.
CZ> Curt
CZ> --
CZ> First, let me assure you that this is not one of those shady pyramid schemes
CZ> you've been hearing about. No, sir. Our model is the trapezoid!
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php