PHP Single Line if else Syntax

By | March 9, 2013

Here is the syntax for single line if else statement in PHP.

<?php
$x=15;
$y=10;
$val=($x<$y)?"Correct":"Incorrect";
echo $val;//Outputs Incorrect
?>

Cheers,
JENSon.


Leave a Reply

Your email address will not be published. Required fields are marked *