update page now
Laravel Live Japan

Voting

: min(six, zero)?
(Example: nine)

The Note You're Voting On

dans at dansheps dot com
14 years ago
Since this was getting me for a little bit, I figure I better pipe in here...
For nested calls to private/protected variables(probably functions too) what it does is call a __get() on the first object, and if you return the nested object, it then calls a __get() on the nested object because, well it is protected as well.
EG:
<?php
class A
{
protected $B
public function __construct()
{
$this->B = new B();
}
public function __get($variable)
{
echo "Class A::Variable " . $variable . "\n\r";
$retval = $this->{$variable};
return $retval;
}
}
class B
{
protected $val
public function __construct()
{
$this->val = 1;
}
public function __get($variable)
{
echo "Class B::Variable " . $variable . "\n\r";
$retval = $this->{$variable};
return $retval;
}
}
$A = new A();
echo "Final Value: " . $A->B->val;
?>

That will return something like...
Class A::Variable B
Class B::Variable val
Final Value: 1
It seperates the calls into $A->B and $B->val
Hope this helps someone

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /