3

我正在构建一个 CodeIgniter 站点,并尝试在控制器中使用php ABTest

我将phpabtest.php 文件保存为“helpers”文件夹中的 phpabtest_helper.php,并将其加载到控制器中。它在 PHP 逻辑中初始化如下:

public function view($name)
    {
    $this->load->helper('phpab');
    $testpopup = new phpab('test_popup');
    $testpopup->add_variation("popup");

    $type = $this->Types->getTypeBySlug($name);
    $data['type'] = $type;
    $data['items'] = $this->Items->getItemsByType($type->id);

    $alltypes = $this->Types->getAll();
    $headerdata['alltypes'] = $alltypes;
    $headerdata['current'] = $type->id;
    $this->load->view('header');
    $this->load->view('typeheader', $headerdata);
    if($testpopup->get_user_segment()=='popup'){
            $this->load->view('type_new', $data);
    } else{
        $this->load->view('type', $data);
    }
    $this->load->view('footer');

}

它在我的本地主机上运行良好,但是当我将它上传到服务器时,它会中断,只显示一个空白页面。我已将问题与new phpab对象的初始化隔离开来。在助手中,它确实如此ob_start(array($this, 'execute'));,这一行似乎是破坏代码的原因。

我应该查看哪些服务器设置才能使其正常工作?我假设这是服务器设置问题,因为它在我的本地主机上运行良好。如果我错了,这是其他问题,我该如何解决?

4

1 回答 1

0

您可能需要检查您的 PHP 设置。您会在您的 php.ini 文件中找到一个名为 output_buffer 的设置,该设置可能设置为 Off。

从 php.ini 执行:

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit.  You can enable output buffering during runtime by calling the output
; buffering functions.  You can also enable output buffering for all files by
; setting this directive to On.  If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).
output_buffering = 4096
于 2013-08-25T17:29:15.617 回答