Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-22-2005, 01:58 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
0 == true PHP5 bug =)

funny thing i ran into today. i have a function something like this:
PHP Code:
<?
function checkthis$var ){
  if( 
$var == 'abcdefg' ){
    return 
'is equal';
  }else{
    return 
'is not equal';
  }
}

echo 
checkthis);
?>
this outputs: is equal in PHP 5.0.3, .. apparently it works in version 5.0.2 ( i found a bug report ) but is still broken in beta 5.1.

it only is a problem with the integer value of 0. if you put quotes around the 0 when sending it into the function, it works as expected.
__________________
Mike
sde is online now   Reply With Quote
Old 07-22-2005, 10:19 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,693
redhead is on a distinguished road
It must be the == operators comparison against NULL that this one fails at.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-22-2005, 11:00 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
after a little more research i found that in PHP5, strings evaluate to 0 when compared to an int.

to me, this doesn't make sense. i think they should leave it as it was in PHP4, and cast 0 to a string and then compare.
__________________
Mike
sde is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Funniest bug report ever. redhead Lounge 6 07-10-2005 12:27 AM
NEED HELP on card assignment marina Standard C, C++ 9 05-03-2005 07:42 AM
true noob Odoggy5 PHP 5 08-22-2003 12:46 PM
bug anon Feedback 10 01-12-2003 03:30 PM
If you can find the bug in this, you are a genius w00t Standard C, C++ 17 08-13-2002 11:17 PM


All times are GMT -8. The time now is 02:22 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting