php create object class scope code example
Example 1: object php
//object init
$object = (object) [
'propertyOne' => 'foo',
'propertyTwo' => 42,
];
Example 2: class php
<?php
class Foo {
public $aMemberVar = 'aMemberVar Member Variable';
public $aFuncName = 'aMemberFunc';
function aMemberFunc() {
print 'Inside `aMemberFunc()`';
}
}
$foo = new Foo;
function getVarName()
{
return 'aFuncName';
}
print $foo->{$foo->{getVarName()}}();