php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #25731 '1d1' == '1e1' ??
Submitted: 2003-10-02 10:22 UTC Modified: 2003-10-02 16:02 UTC
From: md5 at pf dot pl Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: * OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: md5 at pf dot pl
New email:
PHP Version: OS:

 

 [2003-10-02 10:22 UTC] md5 at pf dot pl
Description:
------------
na php5 otrzymuje dwa razy napis "ok"

$a = '1d1';
if($a == '1d1') print('ok');
if($a == '1e1') print('ok');

wyniak z tego ze:
 '1d1' == '1e1'

i taki warunek:
if('1d1' == '1e1') print('ok');
takze pokazuje "ok"

Reproduce code:
---------------
if('1d1' == '1e1') print('ok');
else print('no');

Expected result:
----------------
powinno pojawic sie "no"

Actual result:
--------------
pojawia sie "ok"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-02 10:39 UTC] sniper@php.net
I don't understand polish, but what I understood from the example, this is bogus.

 [2003-10-02 15:59 UTC] marcin dot staniszczak at wp dot pl
:-)

$a = '1d1';
if($a == '1d1') print('ok');
if($a == '1e1') print('ok');

php output:
okok


'1d1' == '1e1' !?

next example:
if('1d1' == '1e1') print('ok');

output:
ok

last example:
if('1d1' == '1e1') 
  print('ok');
else 
  print('no');

output:
ok
I thing, should be: no
 [2003-10-02 16:02 UTC] helly@php.net
Use either === or strcmp()
 [2003-10-04 20:53 UTC] marcin dot staniszczak at wp dot pl
Why we must use ===? In PHP 4.x.x- we can use simply ==... I always use strcmp(), but many people use == to compare strings.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC