ejacky / ejacky.github.io

0 stars 0 forks source link

php 解析问题 #5

Open ejacky opened 4 years ago

ejacky commented 4 years ago

PHP7 中解析 strlen('\n') 是双字节的, strlen("\n") 是单字节的

ejacky commented 4 years ago
    $t = '{"a":"\u003c1\n"}';
    $t1 = json_decode($t, true);
    dump(strlen($t1['a']));

json_decode 会解析 “\u003c1” 为 “<” , 将 \n 解析为 ‘\n’