1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHP \rと\nの違い

Posted at

\r(復帰)と\n(改行)の違い

例1)


echo "これは\rてすとです\n\\rによって一行目の「これは」の上にテストですが重ねられました\n\\rの復帰とは
同じ行の左端に移動する動作であり\n\\nの改行とは同じヘッド位置で、1行下に移動する動作である";

結果
/*てすとです
\rによって一行目の「これは」の上にテストですが重ねられました
\rの復帰とは
同じ行の左端に移動する動作であり
\nの改行とは同じヘッド位置で、1行下に移動する動作である*/

例2) \rを使用すると同じ行の左端に\r以降の記述が上に重ねられる。


echo "これはてすとです\r僕は\n上の一行目の結果は「僕ははてすとです」になるはず";

結果
/*僕ははてすとです
上の一行目の結果は「僕ははてすとです」になるはず
*/

以上

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?