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, ∼2288🔥, 0💬
Popular Posts:
Where to find tutorials on EPUB file format? I want to know how to create EPUB books. Here is a larg...
How to create a "Sign-up or Sign-in" user flow policy in my Azure AD B2C directory? If you want to b...
Where to get a real Atom XML example? You can follow this tutorial to get a real Atom XML example: 1...
Where to get a real Atom XML example? You can follow this tutorial to get a real Atom XML example: 1...
How to access Request body from "context.Request.Body" object in Azure API Policy? Request body is t...