Tools, FAQ, Tutorials:
Comparing Two Strings in PHP
How To Compare Two Strings with Comparison Operators?
✍: FYIcenter.com
PHP supports 3 string comparison operators, <, ==, and >, that generates Boolean values. Those operators use ASCII values of characters from both strings to determine the comparison results. Here is a PHP script on how to use comparison operators:
<?php $a = "PHP is a scripting language."; $b = "PHP is a general-purpose language."; if ($a > $b) { print('$a > $b is true.'."\n"); } else { print('$a > $b is false.'."\n"); } if ($a == $b) { print('$a == $b is true.'."\n"); } else { print('$a == $b is false.'."\n"); } if ($a < $b) { print('$a < $b is true.'."\n"); } else { print('$a < $b is false.'."\n"); } ?>
This script will print:
$a > $b is true. $a == $b is false. $a < $b is false.
⇒ Converting Numbers to Strings in PHP
⇐ Concatenating Two Strings in PHP
2016-10-13, 1541🔥, 0💬
Popular Posts:
How to use the "Ctrl-p Ctrl-q" sequence to detach console from the TTY terminal of container's runni...
Where to find tutorials on Using Azure API Management Developer Portal? Here is a list of tutorials ...
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...
How to use the "rewrite-uri" Policy Statement for an Azure API service operation? The "rewrite-uri" ...