Why would var_dump return a bigger value than the string length?

烂漫一生 提交于 2019-11-29 14:51:37

The likeliest answer is that the string contains non-printable characters beyond "you". To figure out what exactly it contains, you'll have to look at the raw bytes. Do this with echo bin2hex($word). This outputs a string like 666f6f..., where every 2 characters are one byte in hexadecimal notation. You may make that more readable with something like:

echo join(' ', str_split(bin2hex($word), 2));
// 66 6f 6f ...

Now use your favourite ASCII/Unicode table (depending on the encoding of the string) to figure out what individual characters those represent and where you got them from.

Perhaps your string is encoded in UTF-16, in which case you should see telltale 00 bytes every two characters.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!