PHP 5 handles object differently from PHP4
In PHP4
$new_object = $object;
will copy $object to $new_object
In PHP5
The $new_object will point to $ojbect, kind of like Java.
The correct syntax in PHP5 should be:
$new_object = clone($object);
It's all good but create lots of confusion.
To make the two compatible, here's a clone function that works for both PHP 4 and PHP5:
To use the function: $object=php4_clone($old_object); It works on both PHP4 and PHP5Code:/* ************************************** Backward compatible */ function php4_clone($object) { if (version_compare(phpversion(), '5.0') < 0) { return $object; } else { return @clone($object); } }
Ovi
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks