从空值创建默认对象,如何定义值

时间:2013-09-11 14:25:36

标签: php wordpress warnings

我在Wordpress中收到警告信息:

  

“从空值中创建默认对象   /home/forthemde/public_html/wp-content/themes/mayadeep/admin/admin.php   在线225“

此处的代码位于admin.php和:

 function upfw_setup_theme_options(){
     $up_options_db = get_option('up_themes_'.UPTHEMES_SHORT_NAME);
     global $up_options;
     //Check if options are stored properly
     if( isset($up_options_db) && is_array($up_options_db) ):
         //Check array to an object
         foreach ($up_options_db as $k => $v) {
                 $up_options -> {$k} = $v;
         }
     else:
         do_action('upfw_theme_activation');
     endif;
 }
 add_action('upfw_theme_init','upfw_setup_theme_options',10);
 add_action('upfw_admin_init','upfw_setup_theme_options',100);

第225行在这里:

 $up_options -> {$k} = $v;

我试着自己解决,但没有结果。请帮助我,非常感谢您的帮助。

问候。

1 个答案:

答案 0 :(得分:1)

最近我也有这个问题,但这对我有用:

$up_options = new stdClass();

之后添加了global $up_options;

祝你好运, http://shubhinfotech.com http://c-worx.com