《PHP5 项目实战开发详解》第147页有错误
时间:2008-03-11
来源:互联网
3.函数strncmp(), strncmp(string1,string2,length)
<?php
if(strncmp("phpchina","phplinux",3))
{
echo "ok";
}
else {
echo "next";
}
?>
结果:ok //比较前三位,得数据
正确结果应该为:next //前三位相等,返回0;
<?php
if(strncmp("phpchina","phplinux",4))
{
echo "ok";
}
else {
echo "next";
}
?>
结果:next //比较前四位的数据
正确结果应该为:ok //c的ASCII码小于l的ASCII码,返回负数;
第149页可能是印刷错误吧,字符串查找函数返回位置是strpos; 书中写成strops;
[ 本帖最后由 636826 于 2008-3-12 11:00 编辑 ]
<?php
if(strncmp("phpchina","phplinux",3))
{
echo "ok";
}
else {
echo "next";
}
?>
结果:ok //比较前三位,得数据
正确结果应该为:next //前三位相等,返回0;
<?php
if(strncmp("phpchina","phplinux",4))
{
echo "ok";
}
else {
echo "next";
}
?>
结果:next //比较前四位的数据
正确结果应该为:ok //c的ASCII码小于l的ASCII码,返回负数;
第149页可能是印刷错误吧,字符串查找函数返回位置是strpos; 书中写成strops;
[ 本帖最后由 636826 于 2008-3-12 11:00 编辑 ]
作者: 636826 发布时间: 2008-03-11
int strncmp ( string str1, string str2, int len )
This function is similar to strcmp(), with the difference that you can specify the (upper limit of the) number of characters (len) from each string to be used in the comparison.
Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
Note that this comparison is case sensitive.
This function is similar to strcmp(), with the difference that you can specify the (upper limit of the) number of characters (len) from each string to be used in the comparison.
Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
Note that this comparison is case sensitive.
作者: grac 发布时间: 2008-03-11
Therefor ,you are right..
作者: grac 发布时间: 2008-03-11
楼上的怎么尽说英语啊。。。

作者: cnyangqi 发布时间: 2008-03-17
谢谢LZ! 我们会勘误!
作者: 疯狂小猫 发布时间: 2008-03-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28