Skip to content

Instantly share code, notes, and snippets.

@jaspertandy
Created December 6, 2012 15:13
Show Gist options
  • Select an option

  • Save jaspertandy/4225180 to your computer and use it in GitHub Desktop.

Select an option

Save jaspertandy/4225180 to your computer and use it in GitHub Desktop.
PHP being cray.

Only use ===

php -r 'var_dump( "A box of spanners" == 0 ); var_dump( "A box of spanners" == true ); var_dump( 0 == true );'

bool(true) bool(true) bool(false)

@sveneisenschmidt

Copy link
Copy Markdown

Comparison statements cast string to int automatically if one of the other variable is an int.

@jaspertandy

Copy link
Copy Markdown
Author

At least they don't cast boolean to int as well. That'd be confusing as hell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment