Problem with PHP "require"

Web hosting discussion, programming, and shared and dedicated servers.
3 posts Page 1 of 1
by ben1960 » Fri Feb 03, 2017 8:56 am
I'm experiencing a problem with the Sonic server that doesn't occur in my development environment, which uses PHP 5.6.28.

This script also works without problems on the Netfirms.com server, which uses PHP 5.3.

When a PHP script requires an external PHP file, the Sonic server considers headers to have been sent. This means that I can't use the Location header in my PHP scripts.
by joemuller » Fri Feb 03, 2017 4:53 pm
It's extremely likely that you need to turn on output buffering:
For a custom php.ini or .user.ini:

Code: Select all

output_buffering = On
-or-
For .htaccess:

Code: Select all

php_flag output_buffering on
If that doesn't help, I recommend trying the troubleshooting tips that are mentioned in this StackOverflow post:
http://stackoverflow.com/questions/8028 ... n-php?rq=1

In short:
- An optional fix may be to enable output_buffering
- Look at the exact error message complaining about 'Headers already sent' - it should include the file and line number where the error occurred - work from there backwards. There should also be a 'output started at' section in the error that tells you the offending file and line that have generated output prior to your attempting to modify the header.
I'm a proud employee of Sonic.net! :-)
by ben1960 » Sat Feb 04, 2017 6:33 pm
Joe was right. The problem was caused by output buffering being turned off. Joe's first suggestion, involving .user.ini solved the problem. However, the solution involving .htaccess did not work.

Joe's advice regarding the evaluation of error messages is excellent.

Thank you for your help Joe.
3 posts Page 1 of 1

Who is online

In total there are 16 users online :: 0 registered, 0 hidden and 16 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 16 guests