PHP Session Start致命错误:在write |中不能使用函数返回值 进行广泛的故障排除

Fatal error: Can't use function return value in write on line 3

I've looked extensively for an answer to my specific situation with no progress. Please review what I've already tried and I've included my VPS global php.ini file. No php.ini files exist within the website root.

<?php
session_start();
?>
<!DOCTYPE html>
<html>

I have no idea how that's possible. Please check out what I've already done to try to solve the problem.

Problem originated when I was unable to pass variables to another page using $_SESSION['$example'] variables with no luck. But I'll worry about that next.

VPS System Specs Currently (Servers/Networks Are Not My Strong Area)

Apache 3 on CentOS 6.8

  • Default PHP Version | 5
  • PHP 5 Handler | suPHP
  • Apache suEXEC | off
  • Apache Ruid2 | off
  • Default PHP Version (.php files) | 5
  • PHP 5 Handler | suPHP

Attempted Solutions

Disabled .htaccess

.htaccess contains ***suPHP_ConfigPath /***
Header append Vary User-Agent

Prior to disabling:

  • Removed All 301 Rewrite Rules as I've read they interfere with sessions

  • Disabled Error Documents

Ensure No Whitespaces Following session_start();

Caching

  • Turned off all caching through WHM (that I'm aware of)
  • Tested both Firefox and Chrome before and after clearing history/cookies/cache/etc
  • Deleted CloudFlare service for this domain

Additional Information

I Don't have a php.ini file since I use a VPS (in case anyone was wondering)

I use php on almost every other page.

Here is an example of the first few lines of another page.

<?php
session_start();
$ip = $_SERVER['REMOTE_ADDR'];
//Version 1.75

The above code is just the first few lines but the page executes fine without issue. It should be noted that this is a redirect page following a PayPal payment to my website. This issue is recent and previously it has worked fine.

It should also be noted that I use session_write_close(): session_unset(); and session_destroy(); on appropriate pages to unset all $_SESSION variables and terminate sessions.

Below is a link to the php.ini file as text if that helps. The domain contained in the link is not the domain with the issue. I'm not attempting to be "shifty" about the domain with the issue, I just don't want people using the service when it's not working properly.

Global PHP INI File As Text Document

Anyone who solves this, I owe you!

-Andrew

Solved Accidentally

I solved the issues, but still don't know what was causing the Fatal Error

  • Fatal error: Can't use function return value in write on line 3
  • $_SESSION variables didn't pass between pages.

I solved both the Fatal Error issue and the $_SESSION variables problem by doing one thing. For some, this may be standard procedure, but I am self-taught and this did not occur to me. I was making changes to the PHP advanced configuration in WHM and never did not see any changes as a result.

I was banging my head against the wall for two days trying every solution I read in the forums.

Apache Server Restart

I never restarted my Apache Server during this time, both issues were resolved.

While this solution may seem rudimentary or common practice for some, it's easy to overlook. I read at least 30 different forum posts on Stack Overflow and other sites. Not one suggested an Apache Restart as a method to check.

PHP Configuration

I changed my PHP configuration as listed below and my sessions variables were passing.

session.use_cookies = 1
session.use_only_cookies = 1
session.use_trans_sid = 0

Thank you for everyone who took the time to look at this.

Sincerely, Andrew