Articles → PHP → Ternary operator in php

Ternary operator in php
















Software requirement









Technical knowledge





What is a ternary operation?











Syntax


Comparison? result of true comparison : result of false comparison;



Why should I use ternary operator?




if($age < 18)
    echo("Not eligible to vote");
else
    echo("Eligible to vote");




echo ($age < 18?"Not eligible to vote":"Eligible to vote");





Posted By  -  Karan Gupta
 
Posted On  -  Monday, October 13, 2014

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250