简体   繁体   English

PHP严格标准:在wordpress函数中,只能通过引用传递变量

[英]PHP Strict Standards: Only variables should be passed by reference in on wordpress function

i using a wordpress plugin, i notice that returns a error on 我使用了wordpress插件,我注意到该错误返回

$alias = (string)end(array_keys($settings));

above line .the error is PHP Strict Standards: Only variables should be passed by reference in on wordpress function 上面的行。错误是PHP Strict Standards: Only variables should be passed by reference in on wordpress function

i added that function below. 我在下面添加了该功能。 anyone know how to solve that error please, becoz admin dashboard of the plugin not loading because of this error. 任何人都知道如何解决该错误,因为此错误,becoz的插件管理面板未加载。

 /*
            * GET modules lists
            */
            function load_modules ()
            {
                $folder_path = $this->cfg['paths']['plugin_dir_path'] . 'modules/';
                $cfgFileName = 'config.php';

                // static usage, modules menu order
                $menu_order = array();

                foreach(glob($folder_path . '*/' . $cfgFileName) as $module_config ){
                    $module_folder = str_replace($cfgFileName, '', $module_config);

                    // Turn on output buffering
                    ob_start();

                    if( is_file( $module_config ) ) {
                        require_once( $module_config  );
                    }
                    $settings = ob_get_clean(); //copy current buffer contents into $message variable and delete current output buffer

                    if(trim($settings) != "") {
                        $settings = json_decode($settings, true);
                        $alias = (string) end(array_keys($settings));

                        // create the module folder URI
                        // fix for windows server
                        $module_folder = str_replace( DIRECTORY_SEPARATOR, '/',  $module_folder );

                        $__tmpUrlSplit = explode("/", $module_folder);
                        $__tmpUrl = '';
                        $nrChunk = count($__tmpUrlSplit);
                        if($nrChunk > 0) {
                            foreach ($__tmpUrlSplit as $key => $value){
                                if( $key > ( $nrChunk - 4) && trim($value) != ""){
                                    $__tmpUrl .= $value . "/";
                                }
                            }
                        }

                        // get the module status. Check if it's activate or not
                        $status = false;

                        // default activate all core modules
                        if(in_array( $alias, $this->cfg['core-modules'] )) {
                            $status = true;
                        }else{
                            // activate the modules from DB status
                            $db_alias = $this->alias . '_module_' . $alias;

                            if(get_option($db_alias) == 'true'){
                                $status = true;
                            }
                        }

                        // push to modules array
                        $this->cfg['modules'][$alias] = array_merge(array(
                            'folder_path'   => $module_folder,
                            'folder_uri'    => $this->cfg['paths']['plugin_dir_url'] . $__tmpUrl,
                            'db_alias'      => $this->alias . '_' . $alias,
                            'status'        => $status
                        ), $settings );

                        // add to menu order arrayhttp://cc.aa-team.com/wp-plugins/smart-seo-v2/wp-admin/admin-ajax.php?action=pspLoadSection&section=Social_Stats
                        if(!isset($this->cfg['menu_order'][(int)$settings[$alias]['menu']['order']])){
                            $this->cfg['menu_order'][(int)$settings[$alias]['menu']['order']] = $alias;
                        }else{
                            // add the menu to next free key
                            $this->cfg['menu_order'][] = $alias;
                        }

                        // add module to activate modules array
                        if($status == true){
                            $this->cfg['activate_modules'][$alias] = true;
                        }

                        // load the init of current loop module
                        if( $status == true && isset( $settings[$alias]['module_init'] ) ){
                            if( is_file($module_folder . $settings[$alias]['module_init']) ){
                                //if( is_admin() ) {
                                    $current_module = array($alias => $this->cfg['modules'][$alias]); 
                                    require_once( $module_folder . $settings[$alias]['module_init'] );
                                //}
                            }
                        }
                    }
                }

                // order menu_order ascendent
                ksort($this->cfg['menu_order']);
            }

End rereceives value by reference, but result of function is not variable. End通过引用重新接收值,但是功能的结果不是可变的。

You could rewrite your code. 您可以重写代码。

$array_keys = array_keys($settings);
$alias = (string)end($array_keys);
unset($array_keys);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 烦人的PHP错误:“严格的标准:只有变量应该通过引用传递” - Annoying PHP error: “Strict Standards: Only variables should be passed by reference in” 严格标准:只应在functions.php中通过引用传递变量 - Strict Standards: Only variables should be passed by reference in functions.php 严格的标准:只能通过引用传递变量PHP购物车 - Strict Standards: Only variables should be passed by reference PHP Shopping Cart 严格标准:只应通过引用传递变量 - php错误 - Strict Standards: Only variables should be passed by reference - php error PHP 严格标准:在 .lib 中只应通过引用传递变量 - PHP Strict Standards: Only variables should be passed by reference in .lib PHP严格标准:只有变量应通过引用传递给 - PHP Strict Standards: Only variables should be passed by reference in 面向PHP对象的“严格标准:仅变量应通过引用传递给” - PHP Object Oriented “Strict standards: Only variables should be passed by reference in” 严格标准:只有变量应通过引用传递给 - Strict Standards: Only variables should be passed by reference in 严格的标准:只有变量应该通过引用传递 - Strict Standards: Only variables should be passed by reference 严格标准:仅变量应通过引用传递 - Strict Standards: Only variables should be passed by reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM