Dereferencing confusion? What is this example here called?

Posted by perf on Stack Overflow See other posts from Stack Overflow or by perf
Published on 2010-03-14T15:20:54Z Indexed on 2010/03/14 15:25 UTC
Read the original article Hit count: 116

Filed under:

Considering this PHP example:

class A
{
  public function getB( )
  {
    return new B();
  }
}

class B
{
  public function test( )
  {
    echo "Hello";
  }
}

I could use this:

$a = new A( );
$b = $a->getB( );
$b->test( ); // Hello

Or this:

$a = new A();
$a->getB( )->test( ); // Hello

Taking a closer look at the second example...

  • What is the name of this form of expression?
  • Does this have something to do with dereferencing?

  • In which programming languages is this available?

  • What other forms of this exist?

© Stack Overflow or respective owner

Related posts about php