Here's what I want to do:
$var = new ObjectICreated("yay");
echo $var; // outputs "yay" via the __toString() magic method
$var = "Boo"; // $var is still a ObjectICreated, but will now output "Boo" from __toString()
Am I crazy? I think SimpleXML does this very thing, but I'm not sure how. Any thoughts?
Reasoning: I want to track changes to a particular object without having to use billions of getters/setters.
Ok, thanks for the comments, for posterity. SimpleXML DOES do this. The following works based on code from http://www.php.net/manual/en/simplexml.examples-basic.php example #9.
$x = simplexml_load_string($xml); // xml from example #9
// Pre-reference value
print_r($x->movie[0]->characters->character[0]->name);
// Assign to reference of a SimpleXMLElement
$x->movie[0]->characters->character[0]->name = 'Miss Coder';
print_r($x->movie[0]->characters->character[0]->name);
The output is as follows:
SimpleXMLElement Object ( [0] => Ms Coder )
SimpleXMLElement Object ( [0] => Miss Coder )
As you can see, it is still a SimpleXMLElement, as it was prior to the assignment of "Miss Coder".
Thank you again everyone for your time.