Chris Novoa's Most Shallow Depths

3Jun/09Off

__PHP_Incomplete_Class as array

Regarding something to which I found no straight answer in 8 pages of google results:

"Fatal error: Cannot use object of type __PHP_Incomplete_Class as array in"

The offending line was the first instance of a session variable with a certain key name:

if (!isset($_SESSION['user'][0])) { $_SESSION['user'][0] = 0; }

On the development server there were no problems, but put on the demo shared server over which I have no control, the error appeared. I scoured the internet for the solution but it seems anyone who has this problem never really gets a straight answer - and it seems to come up a fair bit. Incidentally, it seems to be related usually to login/user/session management scripts since certain keywords are fairly common in those situations.

Frustrated, as a last ditch attempt I changed it to:

if (!isset($_SESSION['usrinf'][0])) { $_SESSION['usrinf'][0] = 0; }

The problem was solved instantly.

Turns out it was the key "user" which was the problem in the hosting environment.

So if anyone has this issue, do a find/replace of all instances of the session variable key located in the line indicated by the error to something more unique .