array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.strcmp.php', 1 => 'strcmp', ), 'up' => array ( 0 => 'ref.strings.php', 1 => '字符串 函数', ), 'prev' => array ( 0 => 'function.strchr.php', 1 => 'strchr', ), 'next' => array ( 0 => 'function.strcoll.php', 1 => 'strcoll', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/strings/functions/strcmp.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
strcmp — 二进制安全字符串比较
string1
第一个字符串。
string2
第二个字符串。
如果 string1
小于 string2
返回
-1
;如果 string1
大于 string2
返回 1
;如果两者相等,返回 0
。
版本 | 说明 |
---|---|
8.2.0 |
现在此函数返回 -1 或者 1 ,之前返回负数或正数。
|
示例 #1 strcmp() 例子
<?php
$var1 = "Hello";
$var2 = "hello";
if (strcmp($var1, $var2) !== 0) {
echo '$var1 is not equal to $var2 in a case sensitive string comparison';
}
?>