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:

Detect AdBlock with JavaScript in my browser

30-07-2017 AdBlock javascript detect

Time Sorting Ascending or Descending Order in Javascript

19-07-2017 Javascript ascending order descending order

How to convert html to pdf in Node js

12-03-2017 pdf convert html node js

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

09-03-2017 javascript date time

Using slice remove last two characters from given string

07-03-2017 slice remove