classDynamicProperties{}$object=newDynamicProperties;echoisset($object->foo)?'t':'f';// fechoPHP_EOL;// Set Dynamic Properties foo and fooz$object->foo='bar';$object->fooz='baz';// Isset and Unset workisset($object->foo);// trueunset($object->foo);// Iterate through Properties and Valuesforeach($objectas$property=>$value){echo$property.' = '.$value.PHP_EOL;}// Prints:// fooz = baz
classMyClassimplementsCountable,ArrayAccess{...}$myObject=newMyClass();// Using array access notation$myObject[0]='hello';$myObject[1]='world';$myObject['foo']='bar';