Posted By

cessnajumpin on 03/16/10


boolean Ternary

Versions (?)

Simple Variable Handler

 / Published in: PHP

Could be used across a multitude of languages. What this does is check to see if a variable is set, if it is then the variable gets left alone. If not, you define what it defaults to.

The example takes the variable $myFruit, and if it's already been defined it stays as that fruit. If not, then it is defined as the string "apple".

  1. $myFruit = $myFruit ? $myFruit : "apple";

Report this snippet  

You need to login to post a comment.