I wonder how can I rename an object property in PHP, e.g.:
<?php
$obj = new stdclass();
$obj->a = 10; // will be renamed
$obj->b = $obj->a; // rename "a" to "b", somehow!
unset($obj->a); // remove the original one
It does not work in PHP5.3, (donno about earlier versions) since there will be a reference of $obj->a assigned to $obj->b and so by unsetting $obj->a, the value of $obj->b will be null. Any ideas please?
Your code works correctly,
$obj->bis10after execution: http://codepad.org/QnXvueicWhen you unset
$obj->a, you just remove the property, you do not touch to the value. If the value is used by an other variable, it’s left untouched in the order variable.