/ Published in: PHP
Condition = The condition which must be met.
True = Executed if the condition is met.
False = Executed if the condition failes.
True = Executed if the condition is met.
False = Executed if the condition failes.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $var = [condition] ? [true] : [false]; /* the above statement is the same as this more verbose syntax: */ if (condition) { $var = [true]; } else { $var = [false]; } //Example $isNew = false; $output = $isNew ? 'New' : 'Not New'; print($output); // ='Not New'; $isNew = true; $output = $isNew ? 'New' : 'Not New'; print($output); // ='New'; ?>