Source Code:
(back to article)
<?php class SimpleClass { public int $x = 0; } function changeClassProperty(SimpleClass $object): void { $object->x = 1; } // create an instance of the class $instance = new SimpleClass(); // make sure that objects are being passed with the reference by default changeClassProperty($instance); echo $instance->x; ?>
Result:
Report an issue