PHP 提示 Creating default object from empty value 的問題,一般是由于PHP版升級的原因,PHP 5.4 以上的版本一般會報這個錯誤。
解決方法是找到報錯的位置然后看哪個變量是沒有初始化而直接使用的,將這個變量先實例化一個空類。如:
- $ct = new stdClass();
修改文件相應代碼,如:
- if ( ! isset( $themes[$current_theme] ) ) {
- delete_option( 'current_theme' );
- $current_theme = get_current_theme();
- }
- $ct = new stdClass(); <!--添加這行-->
- $ct->name = $current_theme;
問題解決