By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,053 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,053 IT Pros & Developers. It's quick & easy.

how can one copy an object with state?

P: n/a
This doesn't copy state:

$myNewObject = $myOldObject;
This does, but it doesn't copy:

$myNewObject = & $myOldObject;
If I want two objects with the same state, what do I do?
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
lawrence:
This doesn't copy state:

$myNewObject = $myOldObject;


Yes it does.

<?php

class Person {
var $name;
var $age;
}

$me = new Person();
$me->name = "André";
$me->age = 25;

$you = $me;
var_dump($you);

?>

Or do you mean something else by state?

André Nęss
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.