This code works in PHP4:
But it doesn't work on PHP5.PHP Code:$temp = $first_instance_of_class;
$first_instance_of_class = $second_instance_of_class;
$second_instance_of_class = $temp;
![]()
Is there any solution. Thanks in advance.
| SitePoint Sponsor |

This code works in PHP4:
But it doesn't work on PHP5.PHP Code:$temp = $first_instance_of_class;
$first_instance_of_class = $second_instance_of_class;
$second_instance_of_class = $temp;
![]()
Is there any solution. Thanks in advance.
see cloning
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.

I've already tried using cloning like this:
But it does't work either.$temp = clone $first_instance_of_class;
$first_instance_of_class = clone $second_instance_of_class;
$second_instance_of_class = clone $temp;
Why is the code not working for you. I don't think you even need cloning really:
PHP Code:class t {}
$one = new t;
$one->val = 'one';
$two = new t;
$two->val = 'two';
/*
var_dump($one, $two);
object(t)#1 (1) {
["val"]=>
string(3) "one"
}
object(t)#2 (1) {
["val"]=>
string(3) "two"
}
*/
$temp = $one;
$one = $two;
$two = $temp;
/*
var_dump($one, $two);
object(t)#2 (1) {
["val"]=>
string(3) "two"
}
object(t)#1 (1) {
["val"]=>
string(3) "one"
}
*/
sweatje's right. Just tested that on my internal php5 server and worked fine.
Thank god we don't have to do pointer arithmetic in PHP![]()
Mike Lively
Digital Sandwich - MMM MMM Good

Yes, you' right the code above is working perfectly.
Thank you very much for the quick response.
Bookmarks