PHP字符串比较 [英] PHP String Comparison

查看:110
本文介绍了PHP字符串比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个字符串,当我回音他们看起来一样,但当我 var_dump()他们是不同的字符串类型:

I have two strings that look the same when I echo them, but when I var_dump() them they are different string types:

Echo:
http://blah
http://blah
var dump:
string(14) "http://blah"
string(11) "http://blah"
strToHex:
%68%74%74%70%3a%2f%2f%62%6c%61%68%00%00%00
%68%74%74%70%3a%2f%2f%62%6c%61%68

当我比较他们返回false。如何操作字符串类型,以便我可以执行返回true的比较。 string 11和string 14之间有什么区别?我相信有一个简单的决议,但还没有发现任何东西,无论我如何implode,爆炸,UTF8编码等字符串,他们不会比较或更改类型。

When I compare them they return false. How can I manipulate the string type so that I can perform a comparison that returns true. What is the difference between string 11 and string 14? I am sure there is a simple resolution but have not found anything yet, no matter how I implode, explode, UTF8 encode etc the strings they will not compare or change type.

感谢您的帮助!

彼得。

推荐答案

$ clean_str = trim($ str );

这篇关于PHP字符串比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆