執行 ❯
獲取您
自己的 PHP
伺服器
×
更改方向
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <body> <?php class MyClass { public $amount; } // Create an object with a reference $value = 5; $obj = new MyClass(); $obj->amount = &$value; // Clone the object $copy = clone $obj; // Change the value in the original object $obj->amount = 6; // The copy is changed print_r($copy); ?> </body> </html>
MyClass Object ( [amount] => 6 )