I’m about to punch PHP in the nads. I’ve got an incredibly simple operation that is basically acting with a mind of it’s own.
$this->user = $this->processToken($token);
if(!isset($this->user))
{
$this->sendError(401);
}
w/ a valid $token this sends a 401, which it shouldn’t. But this:
$this->user = $this->processToken($token);
print_r($this->user);
if(!isset($this->user))
{
$this->sendError(401);
}
works without a hitch, except for the fact that I now have an array printed out on the screen. $user is a VO, replacing print_r(...) with echo $this->user->name has the produces the same result (sans array of course).
EDIT:
I should add, the operation after this returns an incremented int. Which even when the error is sent still increments (as long as the token is correct). So it does look like the header is overriding the end result. I would have thought the if would prevent the header from getting written though?
UPDATE
To make things weirder. If I echo ''; in the same place, it doesn’t override anything, and the error still gets displayed…. again, even with good token.
print_r()nullifies the header401 Unauthorizedsent to the browser – which now results inHeaders already senterror.