Reputation:
First things first, I'd like to make sure the below is the right way to test and clone an object. I'm using the PHP Simple HTML DOM Parser.
$page = 'www.google.ca';
$html = file_get_html($page);
$test = clone $html;
$test->find('title',0)->innertext = 'changed title';
echo $html->find('title',0)->innertext;
echo $test->find('title',0)->innertext;
Now maybe I'm doing it wrong, but this doesn't seem to clone $html to $test. Both will output 'changed title'.
So my question(s) is,
Thanks guys
Upvotes: 0
Views: 574
Reputation: 1016
The documantation says so:
When an object is cloned, PHP 5 will perform a shallow copy of all of the object's properties. Any properties that are references to other variables, will remain references.
So maybe .innertext refers to another object, and it's a reference.
Have you tried $test = $html;
?
Upvotes: 1