CodeIgniter与PHPABTest
问题描述:
我正在构建一个CodeIgniter网站,并试图在控制器中使用php ABTest。CodeIgniter与PHPABTest
我将phpabtest.php file作为phpabtest_helper.php保存在“helpers”文件夹中,并将其加载到控制器中。它在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');
}
它正常工作在我的本地,但是当我把它上传到服务器上,它打破了,只是显示一个空白页。我已经将问题隔离到了对象的初始化。在帮手中,它的确是ob_start(array($this, 'execute'));
,这条线似乎是破坏代码的东西。
我应该查看哪些服务器设置才能使其运行?我假设这是一个服务器设置问题,因为它在我的本地主机上正常工作。如果我错了,这是其他问题,我该如何解决这个问题?
答
你可能想检查你的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
得到本地主机与服务器相同的PHP版本?同一台服务器 – vidario