April 2026
Intermediate
1009 pages
34h 15m
English
You already know the simple string comparison from Chapter 5. With exact equality and exact inequality, you can even check the data type.
4 === "4"
therefore results in false.
PHP's string functions now provide a few more comparisons that go beyond this basic check.
The strcmp(String1, String2) and strcasecmp(String1, String2) functions are used to perform a binary comparison with two strings. The only difference is that strcasecmp() is not case-sensitive. In contrast to the comparison with the corresponding comparison operators, the functions return the result of which string is larger. If String1 is smaller, the return value is less than 0; if both strings are the same, the return value is 0
Read now
Unlock full access