From:             
Operating system: 
PHP version:      Irrelevant
Package:          Variables related
Bug Type:         Feature/Change Request
Bug description:"is" operator -- test whether two lvalues are references to 
each other

Description:
------------
Currently, PHP has "==", which loosely checks for equality, and "===",
which 

strictly checks for equality.  However, for strings and booleans and such,
both 

only test for equality -- there's no way to know (without altering the
variable's 

contents) whether two variables are identical references unless they refer
to an 

object.



If PHP allows the creation of references, there should be some safe and
built-in 

way of testing whether that's been done, so values don't get unexpectedly
mangled.

Test script:
---------------
$a = 'test';

$b = "$a";  // Interpolated, so it should not be pooled or anything if PHP
does that

$c =& $a;   



// These all print

if ($a == $b) print "\$a == \$b\n";

if ($b == $c) print "\$b == \$c\n";

if ($a == $c) print "\$a == \$c\n";



// These all print too, as expected

if ($a === $b) print "\$a === \$b\n";

if ($b === $c) print "\$b === \$c\n";

if ($a === $c) print "\$a === \$c\n";



// I use "is" here, because other languages use it

// if they don't already use /==+/ for this purpose.

if ($a is $b) print "\$a is \$b\n"; // should not print

if ($b is $c) print "\$b is \$c\n"; // should not print

if ($a is $c) print "\$a is \$c\n"; // should run

Expected result:
----------------
$a == $b

$b == $c

$a == $c

$a === $b

$b === $c

$a === $c

$a is $c

Actual result:
--------------
Parse error.  (There is no "is" operator yet, and no reasonable
replacement.)

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52907&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52907&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52907&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52907&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52907&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52907&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52907&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52907&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52907&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52907&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52907&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52907&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52907&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52907&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52907&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52907&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52907&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52907&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52907&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52907&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52907&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52907&r=mysqlcfg

  • [PHP-BUG] Req #52907 [NEW]: "is&q... a_different_name at hotmail dot com

Reply via email to