comparison in php code example
Example 1: string compare in php
//In php to compare two string we can use strcmp() function
Syntax
strcmp(string1,string2);
//If both string is same then it will return 0
<?php
echo strcmp("Hello world!","Hello world!");
?>
Example 2: php if less than number
<?php
if ($a > $b)
echo "a is bigger than b";
?>
Example 3: php ?:
// Example usage for: Ternary Operator
$action = $_POST['action'] ?: 'default';
// The above is identical to this if/else statement
if (empty($_POST['action'])) {
$action = 'default';
} else {
$action = $_POST['action'];
}