Boh*_*vel 1 php string-comparison
我的PHP代码:
$hello = "Hello, world! ";
echo $string1 = sprintf("%'#-20s\n", $hello); // Displays "Hello, world! ######"
echo $string2 = str_pad($hello, 20, "#"); // Displays "Hello, world! ######"
echo ($string1 == $string2) ? "Indeed they're equal" : "They're not equal";
// Displays "They're not equal"
echo strcmp($string1, $string2); // Displays "-1", which (according to PHP Manual)
// means that $string1 is less than $string2
Run Code Online (Sandbox Code Playgroud)
字符串$string1和$string2不相等的原因是什么?
| 归档时间: |
|
| 查看次数: |
331 次 |
| 最近记录: |