Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 短代码显示在错误的位置,总是在顶部_Php_Position_Return_Shortcode_Ob Start - Fatal编程技术网

Php 短代码显示在错误的位置,总是在顶部

Php 短代码显示在错误的位置,总是在顶部,php,position,return,shortcode,ob-start,Php,Position,Return,Shortcode,Ob Start,我在一家网店工作,它将在结账前展示购物车。就像现在一样,这是购物车之前的结账 我不能让它工作。 我遇到了一个问题,插件总是显示在内容的顶部。 我一周前就修好了。现在,我更新了插件,并尝试了同样的事情,你可以在按钮听到 代码是这样的: public function __construct() { add_action('init', array( &$this, 'start_session' ), 1); add_shortcode( 'woocommerce_kl

我在一家网店工作,它将在结账前展示购物车。就像现在一样,这是购物车之前的结账

我不能让它工作。 我遇到了一个问题,插件总是显示在内容的顶部。 我一周前就修好了。现在,我更新了插件,并尝试了同样的事情,你可以在按钮听到

代码是这样的:

public function __construct() {

    add_action('init', array( &$this, 'start_session' ), 1);

    add_shortcode( 'woocommerce_klarna_checkout', array(&$this, 'klarna_checkout_page') );

    //add_action( 'woocommerce_proceed_to_checkout', array( &$this, 'checkout_button' ), 12 );

    add_filter( 'woocommerce_get_checkout_url', array( &$this, 'change_checkout_url' ), 20 );



}

// Set session
function start_session() {      

    $data = new WC_Gateway_Klarna_Checkout;
    $enabled = $data->get_enabled();

    if(!session_id() && $enabled == 'yes') {
        session_start();
    }
}

// Shortcode
function klarna_checkout_page() {

    $data = new WC_Gateway_Klarna_Checkout;
    $data->get_klarna_checkout_page();


    }
我试过这样做:

            ob_start();
    $data->get_klarna_checkout_page();
    $output_string=ob_get_contents();;
    ob_end_clean();

    return $output_string;
比洞还大,唯一能显示的是/*

正如我在顶部所写的,这个解决方案在插件的更高版本上工作,但现在不行。 我在韦伯能找到的就是这个解决方案。如果有人知道我会喜欢的

可能问题在于我放ob_start()的函数中没有短代码?
我像一个php新手,似乎自己无法实现这一点。

shortcode函数不会返回任何东西?正如我在文章中所写,Iam是一种新的whit php。那么,我应该返回什么呢?就像前面提到的那样,aim在php上不是很好,但在我看来,我确实返回了它,其中有:$output_string=ob_get_contents();;稍后:返回$output_字符串;我说的对吗?也只试过一次;没有任何区别。