- var_dump: documentation ( source)
- is_callable: documentation ( source)
<?php
class Foo {
protected $foo;
function __construct($foo)
{
$this->foo = $foo;
}
function modify($foo)
{
$o = clone $this;
if (is_callable($o, '__construct')) {
$o->__construct($foo);
}
return $o;
}
function getFoo()
{
return $this->foo;
}
}
$f = new Foo("foo");
var_dump($f->getFoo());
var_dump($f->modify("bar"));