這是一段php代碼
if(file_exists($file_path)){
$str = file_get_contents($file_path);
echo "window.location.href=\"http://xxxx.xxx/xxx/xxx_".$str."";
如果直接這麼輸出,那麼文件中的\n字符也會作用與html上,與html不同的是js的\n直接被轉譯爲換行而不是<\b\r/>這個我們都知道的,換行之後js代碼是不能往下執行的所以我們必須要把\t去掉
$str = str_replace("\r\n","",$str);
$str = str_replace("\n","",$str);
這樣就可以正常執行了