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, ∼3093🔥, 0💬
Popular Posts:
How to build a test service operation to dump everything from the "context.Request" object in the re...
How to use the "return-response" Policy statement to build the response from scratch for an Azure AP...
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encod...
How to use the API operation 2017 version setting "Rewrite URL template"? The API operation setting ...
How to add request URL Template Parameters to my Azure API operation 2017 version to make it more us...