PHP Simple HTML DOM Parser's way of creating an attribute
file_get_html("http://google.com")->find('body')->bgcolor = '&675432';
on PHP 5.6.13 causes a warning
Creating default object from empty value
.
Is there some way to create an attribute without such a warning without changing the error reporting level or defacing the code as per Creating default object from empty value in PHP? ?
That defacement is having to create an object manually where the object doe not exist, but in the example above, it does.
EDIT: var_dump(file_get_html("http://google.com")->find('body'));
gives
array(1) { [0]=> object(simple_html_dom_node)#18 (9) { ["nodetype"]=> int(1) ["tag"]=> string(4) "body" ["attr"]=> array(1) { ["bgcolor"]=> string(4) "#fff" } ["children"]=> array(6) { [0]=> object(simple_html_dom_node)#19 (9) { ["nodetype"]=> int(1) ["tag"]=> string(6) "script" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(1) { [0]=> object(simple_html_dom_node)#20 (9) { ["nodetype"]=> int(3) ["tag"]=> string(4) "text" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> RECURSION ["_"]=> array(1) { [4]=> string(16) "noise 1007" } ["tag_start"]=> int(0) ["dom":"simple_html_dom_node":private]=> object(simple_html_dom)#1 (23) { ["root"]=> object(simple_html_dom_node)#2 (9) { ["nodetype"]=> int(5) ["tag"]=> string(4) "root" ["attr"]=> array(0) { } ["children"]=> array(2) { [0]=> object(simple_html_dom_node)#3 (9) { ["nodetype"]=> int(6) ["tag"]=> string(7) "unknown" ["attr"]=> array(0) { } ["children"]=> array(0) { } ["nodes"]=> array(0) { } ["parent"]=> RECURSION