php - String of file_get_html can't be edited?
file_get_html() returns an object, not a string. Attempting to concatenate a string to an object will call the object's
_toString() method if it exists, and the operation returns a string. Strings do not have a
If you want to do as you have described read the file contents and concatenate the extra string first:
$content = file_get_contents('someFile.html'); $content .= "someString"; $domObject = str_get_html($content);
Alternatively, read the file with
file_get_html() and manipulate it with the DOM API.
$doois not a string! It's an object, an instance of Simple HTML DOM. You can't call
->methods on strings, only on objects. You cannot treat this object like a string. Trying to concatenate something to it makes no sense.
$abdin your code is the result of an object concatenated with a string; this either results in a string or an error, depending in the details of the object. What it certainly does not do is result in a usable object, so you certainly can't do
If you want to modify the content of the page, do it using the DOM API which the object gives you.