Monthly Archives: October 2014

If else shortcut

The general format

(condition) ? (true return value) : (false return value)


echo ‘Based on your score, you are a ‘,($score > 10 ? ‘genius’ : ‘nobody’);


Add days to a date

$adate = '2013-12-10'; //can use Ymd or mdY. Can't use dmY. Can use dash or slash to separate
$daystoadd = 7;
$newdate = date('Y-m-d',strtotime($adate) + (24*3600*$daystoadd)); //the date format is for output