- var_dump: documentation ( source)
<?php
class X
{
}
class XFactory
{
private $className = 'X';
private function getClassName()
{
return $this->className;
}
public function create()
{
return array(
'member without parens' => new $this->className,
'member with parens' => new $this->className(),
// 'method without parens' => new $this->getClassName, # Does not work at all
'method with parens' => new $this->getClassName(),
'method with double parens' => new ($this->getClassName())(),
'method with encapsed parens' => new ($this->getClassName())(),
);
}
}
$factory = new XFactory();
var_dump($factory->create());