1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?php class foo { public $bar = 'default'; } function change($obj) { $obj->bar = 'Hello world'; } function myPrint($obj){ echo $obj->bar; } $object = new foo(); change($object); myPrint($object);
1
Hello world