php字串比较有关问题,看起来明明一样,strcmp比较结果始终不为0

WBOY
Release: 2016-06-13 12:59:19
Original
1044 people have browsed it

php字串比较问题,看起来明明一样,strcmp比较结果始终不为0
一个从页面传入 id值是1 ,
一个是从文件里面读取的id值是1
使用strcmp比较的时候始终不等,然后用strlen来测试字串长度 传入的1的长度居然是0,从文件里面读取到的1长度是1.现在考虑是编码不一致引起的,但是怎么设置啊?请指教,谢谢。
------解决方案--------------------
你看看你的文件的编码 是什么 
转变哈


然后看看你的代码文件的编码是什么 转变哈
------解决方案--------------------
还是要看代码,长度为0是奇怪的
------解决方案--------------------
五码无真相,贴出代码看看。
------解决方案--------------------
确认你的值传入了...
------解决方案--------------------
我之前也遇到过 就是两个值 在页面输出看起来是一样 比较是返回false的  
不过我的情况不一样,我那个"变质"的值是因为经过一层层打包 再拆封 传输,才变质的。
因为变质的值strlen非常长,我后面是用trim()去掉空格 进行比较才返回true.LZ的比较奇怪 直接就是0了 LZ再比较比较吧 用gettype dump 输出 看看有什么不一样~
------解决方案--------------------
是不是值没有传过来,仔细检查下看看,
可以的话把代码拿过来看看,

Related labels:
source:php.cn
Statement of this 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!