Shorthand PHP if else Statements

Am playing with some OOP PHP again and have found a nifty way to cut down short if else statement

return ($count == 1 ? 'Incorrect password' : 'Incorrect username.');

is the same as

if ($count == 1 ) {
return 'Incorrect password';
} else {
return 'Incorrect username.';
}

Bargain!

Shane

Share and Enjoy:
  • TwitThis
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • Technorati
  • Live
  • MySpace
  • Pownce
  • Reddit
  • Tumblr

If you liked this then check out these

Tags:

One Response to “Shorthand PHP if else Statements”

  1. asystematic says:

    thx man! :)

Leave a Reply