General Musing

blaze your trail

Bad typecasting in PHP #programming

leave a comment »

PHP really annoys me sometimes, such as with the example below. Interpreting and casting the string value “zero” to 0.

<?php
if("NULL" == NULL)
echo "bad code!";
else
echo "good code!";
?>

good code!

<?php
if("zero" == 0)
echo "bad code!";
else
echo "good code!";
?>

bad code!

Technorati technorati tags: , , , ,

Written by Daniël W. Crompton (webhat)

May 12, 2009 at 1:17 pm

Posted in programming

Tagged with , , , ,

Please Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: