Link Details

Link 57648 thumbnail
User 238392 avatar

By davidwalsh
via davidwalsh.name
Published: Dec 18 2007 / 10:13

In looking at my Google Analytics statistics, I see a lot of visitors searching for PHP shorthand if/else (ternary) information. I've gone through my code library and picked out some examples of ternary operator usage.
  • 12
  • 1
  • 2198
  • 598

Comments

Add your comment
User 261350 avatar

harlan replied ago:

0 votes Vote down Vote up Reply

Nice post dwizzle

User 256617 avatar

dragmire replied ago:

0 votes Vote down Vote up Reply

Ternary ifs are difficult to read. Avoid unless you can somehow make it easier.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (12)



Voters Against This Link (1)