Example for Conditional Operator in php

Conditional Operator

Try following example to understand the conditional operator.

$a = 10;
$b = 20;

 /* If condition is true then assign a to result otheriwse b */
$result = ($a > $b ) ? $a :$b;
echo $result;

Here $a is if condition and $b is in else condition.



You might also like:

A Very Big Sum | Javascript | hackerrank

07-05-2020 A Very Big Sum Javascript hackerrank

Time Sorting Ascending or Descending Order in Javascript

19-07-2017 Javascript ascending order descending order

How to get id by using name attribute in javascript

20-03-2017 html id name javascript

How to get current date and time (yyyy-mm-dd H:i:s) using javascript

09-03-2017 javascript date time

Change datepicker display format

06-03-2017 datepicker angular js