oop - PHP - Is there a way to initialize a class and call a non-static method in one line? -
oop - PHP - Is there a way to initialize a class and call a non-static method in one line? -
can point me in right direction minimize these 2 lines of php
single line?
$foo = new foo; $x = $foo->getbar();
i've tried following, didn't desired result..
$x = new foo()->getbar();
also, possible in yii, using cmodel
object:
$x = foo::model()->getbar();
is effect achievable in non-framework php without model()
static method?
it's possible 5.4
$x = (new foo())->getbar();
php oop
Comments
Post a Comment