Fatal error: Cannot re-assign auto-global variable _POST

后端 未结 3 1701
迷失自我
迷失自我 2020-12-17 16:01

I can\'t get access to my WP (version3.4.2) admin. It says as mentioned above

Fatal error: Cannot re-assign auto-global variable _POST in /home/xxx/p

3条回答
  •  清酒与你
    2020-12-17 16:49

    @user3450716. You can't change superglobal variables too, so you can't use unset($_POST[$key])

    function rt_check_sidebar_array(){
        $post = $_POST;
        if(is_array($post)){
    
            $start_unset_count = 0;
    
            foreach( $post as $key => $value ){
                if( stristr( $key, '_sidebar_name' ) == TRUE && $value == "" ) {                  
                    unset( $post[ $key ] );
                    $start_unset_count = 1;
                }
    
                if( $start_unset_count > 0 ){
                    unset( $post[ $key ] );
                    $start_unset_count++;
                }
    
                if( $start_unset_count == 6 ){
                    $start_unset_count = 0;
                }               
            }
        }
    
        // idk why you wrote this,
        // because $newPost variable isn't used in the code above and below
        $newPost == $newPost ? $newPost : $post;
    
        return $post;
    }
    

提交回复
热议问题