当字符串包含标点符号时检查字符串是否相等


Checking for string equality when the string contains punctuation

当标点标记在字符串中时,PHP 可以检查相等吗?我尝试将hello'hello'进行比较,与==相比,它们并不相等。

它正确地比较字符串:

"hello'" == "hello'" // true

代码板

你一定做错了什么。也许您在单个带引号的字符串中使用'而没有像''那样对其进行转义,并且得到了奇怪的结果。