【问题标题】:CodeIgniter with PHPABTestCodeIgniter 与 PHPABTest
【发布时间】:2013-06-28 06:03:33
【问题描述】:

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

我将phpabtest.php file 保存为“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'));,这行似乎是破坏代码的原因。

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

【问题讨论】:

  • 在本地主机和服务器上获得相同的 PHP 版本?同一台服务器?

标签: php codeigniter ob-start


【解决方案1】:

您可能需要检查您的 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

【讨论】:

    猜你喜欢
    • 2012-11-01
    • 2012-01-15
    • 2019-04-04
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    • 2013-09-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多