/ Published in: PHP
Condition = The condition which must be met. True = Executed if the condition is met. False = Executed if the condition failes.
Expand |
Embed | Plain Text
<?php $var = [condition] ? [true] : [false]; /* the above statement is the same as this enlarged structure: */ if (condition) { $var = [true]; } else { $var = [false]; } //Example $isNew = false; $output = $isNew ? 'New' : 'Not New'; $isNew = true; $output = $isNew ? 'New' : 'Not New'; ?>
You need to login to post a comment.
