\\\\r\\\\n 一般一起用,用來表示鍵盤上的回車鍵(Linux,Unix中),也可只用 \\\\n(Windwos中),在Mac OS中用\\\\r表示回車。
\\\\t表示鍵盤上的“TAB”鍵。
文件中的換行符號:windows : \\\\n,linux,unix: \\\\r\\\\n
補(bǔ)充代碼:
<?php
//php 不同系統(tǒng)的換行
//不同系統(tǒng)之間換行的實現(xiàn)是不一樣的
//linux 與unix中用 /n
//MAC 用 /r
//window 為了體現(xiàn)與linux不同 則是 /r/n
//所以在不同平臺上 實現(xiàn)方法就不一樣
//php 有三種方法來解決
//1、使用str_replace 來替換換行 $str = str_replace(array("/r/n", "/r", "/n"), "", $str);
//2、使用正則替換 $str = preg_replace('//s*/', '', $str);
//3、使用php定義好的變量 (建議使用) $str = str_replace(PHP_EOL, '', $str);
?>
PHP_EOL是一個已經(jīng)定義好的變量,代表php的換行符,這個變量會根據(jù)平臺而變,在windows下會是/r/n,在linux下是/n,在mac下是/r。
去除換行符換行就按下面的就可以了:
$str = str_replace(PHP_EOL, '', $str);
相關(guān)推薦:php培訓(xùn)
更多關(guān)于云服務(wù)器,域名注冊,虛擬主機(jī)的問題,請訪問西部數(shù)碼官網(wǎng):m.ps-sw.cn