#45566 [Opn->Fbk]: Strict comparision on $_SERVER values fail

From: Date: Tue, 22 Jul 2008 22:33:31 +0000
Subject: #45566 [Opn->Fbk]: Strict comparision on $_SERVER values fail
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-127149@lists.php.net to get a copy of this message
 ID:               45566
 Updated by:       jani@php.net
 Reported By:      samuel at slbdata dot se
-Status:           Open
+Status:           Feedback
 Bug Type:         Strings related
 Operating System: Ubuntu 8.04.1
 PHP Version:      6CVS-2008-07-19 (snap)
 New Comment:

Try var_dump() on those variables.


Previous Comments:
------------------------------------------------------------------------

[2008-07-19 20:43:38] samuel at slbdata dot se

Description:
------------
Comparing a string in the $_SERVER superglobal using the strict
equality operator (===) always fails, even though both types are
strings. $_GET and other variables work fine.

I'm using the php.ini-recommended file, with no changes except for
display_(startup_)errors which are enabled. My locale is sv_SE.UTF-8
(the LANG environment variable is set to this value)

This used to work fine in php6.0-200804260630

Reproduce code:
---------------
<?php

$rm = $_SERVER['REQUEST_METHOD'];
echo "Type is: ".gettype($rm)." <br />\n";
if (($rm !== 'GET') && ($rm == 'GET')) {
  echo "Bug! <br />\n";
} else {
  echo "Correct behaviour! <br />\n";
}


$sp = $_SERVER['SERVER_PROTOCOL'];
echo "Type is: ".gettype($sp)." <br />\n";
if (($sp !== 'HTTP/1.1') && ($sp == 'HTTP/1.1')) {
  echo "Bug! <br />\n";
} else {
  echo "Correct behaviour! <br />\n";
}


Expected result:
----------------
Type is: string
Correct behaviour! 
Type is: string
Correct behaviour! 


Actual result:
--------------
Type is: string
Bug!
Type is: string
Bug! 



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45566&edit=1



Thread (6 messages)

« previous php.bugs (#127149) next »