0

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

2 Answers 2

1

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);
Sign up to request clarification or add additional context in comments.

1 Comment

thanks now warnings removed.. i use $searchresult[$pluginname][$i]=new stdClass();.... also Lawrence Cherone suggests... thanks everybody for your kind help.. Regards
0

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.

1 Comment

Thanks Rob...Currently i m using it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.