Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 3.x + XenForo 1.5 + PHP native 5.3
#1

Hi everyone,

I have website based on CodeIgniter 3.x closely integrated with XenForo 1.5.
Website uses XenForo user management so XenForo library is invoked on almost every page specially when user is logged in.

It works fine with PHP native 5.3. But when I change PHP version to any between 5.3 and 5.6, it behaves abnormally on frontend (views).

For example, I have these three files:

index.php
Code:
<?php $this->load->view('header'); ?>
This is index file.
<?php $this->load->view('footer'); ?>

header.php
Code:
This is header file.

footer.php
Code:
This is footer file.

Output should be, which is fine with PHP native 5.3:
Code:
This is header file.
This is index file.
This is footer file.

But on others, output is something like this:
Code:
This is header file.
This is footer file.
This is index file.

So clearly, its loading $this->load->view() before the actual content even though footer file is loaded at the bottom.

It works fine if its CodeIgniter only. But when I include XenForo autoloader in the constructor it doesn't (no matter which version except native 5.3).

It works fine if PHP version is native 5.3 with CI and XenForo both together. Not with 5.3, 5.4, 5.5 or 5.6.

Any help will be appreciated.

Regards,
Puneet
Reply
#2

For some context: when you call $this->load->view('filename'), the loader starts the output buffer, loads the file, and appends the content to the buffer (it also manages nesting to allow you to calling $this->load->view() from inside a view). Eventually it sends the buffer to CI's output class, which eventually sends everything to the browser.

So, what are the potential causes for the behavior you're seeing?
- something (most likely XenForo) started output before you loaded the view(s)
- something (still most likely XenForo) tried to manipulate CI's environment and messed it up

The first is the most likely of the two, and if it's only happening with certain versions of PHP, I would guess that you're getting an error somewhere (which will often start output early). Any use of echo, print, or similar language features/functions/methods can start output, and should never be done anywhere other than a view.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB