This works in PHP:
class Foo{
....
}
function Foo(){return new Foo();}
Is this a safe / wise practice in PHP? (in the sense that this may cause problems now or in future versions)
The reason for using this is to somehow make the code more understandable this way:
class Foo{
var $bar,$hold;
function setBar($how=true){$bar=$how;return $this;}
function setHold($how=true){$hold=$how;return $this;}
}
function Foo(){return new Foo();}
$someFoo=Foo()->setBar()->setHold(false);
which could make the code more readable and / or preserve some typing.
Joan source
share