3

I'm building a CodeIgniter site, and attempting to use php ABTest in the controller.

I saved the phpabtest.php file as phpabtest_helper.php in the "helpers" folder, and loaded it in the controller. It's initialized in the PHP logic as such:

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');

}

It works fine on my localhost, but when I upload it to the server, it breaks, just displaying a blank page. I've isolated the problem to the initialization of the new phpab object. In the helper, it does ob_start(array($this, 'execute')); and this line seems to be what is breaking the code.

What server settings should I be looking at to get it to work? I'm assuming it's a server setting issue because it works fine on my localhost. If I'm wrong and it's some other issue, how do I fix this?

Hashem Qolami
  • 97,268
  • 26
  • 150
  • 164
derrickkwa
  • 51
  • 2

1 Answers1

0

You might want to check your PHP settings. You'll find a setting called output_buffer in your php.ini file that might be set to Off.

Exert from 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
Regican
  • 71
  • 1
  • 4