close
前幾天幫忙trace一個神奇的bug, 後來經某高人指點, 才知道原來是locale設定搞的鬼@@
see http://www.regextester.com/pregsyntax.html
"in the "fr" (French) locale, some character codes greater than 128 are used for accented letters, and these are matched by \w ."
我碰的問題是:
以下這行在兩台機器有不同的行為@@
$word = preg_replace('/\s+/', ' ', $word);
in BOX 1:
233 155 178 231 133 153
233 155 178 231 32 153
in BOX 2:
233 155 178 231 133 153
233 155 178 231 133 153
以上是將文字dump成十進位表示,
Box1上會將133視為"\s"所以會被換成空白(32)
後來將\s改成(?:[\t ]| )解決的 :P
全站熱搜