简体   繁体   中英

What's wrong with this strpos and ternary operator?

strpos($mydata,'Εntity') === false) ? 'normal' : 'other'

即使它总是返回“正常”

 $mydata="Entity: This data must work." 

As I though your string has a weird encoding if you take a look into a hex editor and compare the Entity from your string and from the strpos call you will see the difference:

//string
45 6e 74 69 74 79  
//strpos call
ce 95 6e 74 69 74 79 

So to solve this now, just don't copy it from here on SO just write it normal with your keyboard and all should work fine. The proof here: http://3v4l.org/lbL4v

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM