php警告Creating default object from empty value 问题的解决方法


  本文标签:php,Warning

解决方法是找到报错的位置然后看哪个变量是没有初始化而直接使用的,将这个变量先实例化一个空类 。如:

复制代码 代码如下:
$ct = new stdClass();

修改文件相应代码,如:
复制代码 代码如下:
if ( ! isset( $themes[$current_theme] ) ) {
 delete_option( current_theme );
 $current_theme = get_current_theme();
}
$ct = new stdClass(); <!--添加这行-->
$ct->name = $current_theme;

问题解决 。