Source Code:
(back to article)
<?php class MyClass { /** * @var int */ private int $myProperty; public function __construct() { $this->myProperty = 0; } public function getMyProperty(): int { return $this->myProperty; } public function setMyProperty(int $value): void { $this->myProperty = $value; } } $object = new MyClass(); $propertyName = 'getMyProperty'; echo $propertyValue = $object->{$propertyName}();
Result:
Report an issue