0
votes

I have a problem related to php version 5.4. I am using php5.4. Before it was 5.2.

Now I have problem after upgrading. Now my site has lots of warnings

Creating default object from empty value

I am trying to solve this by checking other posts, but no success.

Warnings are at this line

$searchresult[$pluginname][$i]->title = $value->title;
2
You cant do what your doing, unless you initialize $searchresult[$pluginname][$i] as a stdClass() first or create a special __set() method in the class.Lawrence Cherone

2 Answers

1
votes

Yes, with older versions of PHP, you could do :

$a = null;
$a->somevar = 3;`

Because $a was automaticly turned into stdClass type.

With PHP 5.4 you can't do that : you have to instanciate $a manually.

$a = new stdClass(); 
$a->somevar = 3;`

Or better, use arrays if you can :

$a = array('somevar' => 3);
0
votes

This is the stupid way to approach this problem, but you get that warning off you back by setting error_reporting to E_ALL & ~E_NOTICE & ~E_STRICT.

It's specially helpful if you're going to do the wrong thing any way and not rewrite the code as @theredled suggests above.