Note: The strcmp() function is binary safe and case-sensitive.
Tip: This function is similar to the strncmp() function, except that with strncmp() you can specify the number of characters for each string to be compared.
Syntax
strcmp(string1,string2)
Copy after login
Parameters
Description
string1
Required. Specifies the first string to compare.
string2
Required. Specifies the second string to be compared.
<?php
echo strcmp("Hello world!","Hello world!"); // the two strings are equal
echo strcmp("Hello world!","Hello"); // string1 is greater than string2
echo strcmp("Hello world!","Hello world! Hello!"); // string1 is less than string2
?>
The above is the detailed content of PHP function strcmp() that compares two strings (case sensitive). For more information, please follow other related articles on the PHP Chinese website!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn