after upgrading my php5.4 Creating default object from empty value
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;
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.
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);
链接地址: http://www.djcxy.com/p/59392.html
下一篇: 升级我的php5.4从空值创建默认对象后