Ternary

Tests if a condition is true or false

 

condition ? true : false ;

 

<?php
	$myVar = 42 ;

	echo $myVar < 50 ? "Value is True" : "Value is False" ;

	echo "<br><br>" ;

	$yourVar = ($myVar < 40) ? "Value is True" : "Value is False" ;

	echo $yourVar ;
?>

Leave a Reply