php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63427 echo or print don t print spaces and new lines
Submitted: 2012-11-03 12:50 UTC Modified: 2012-11-06 06:18 UTC
From: abelahcene at gmail dot com Assigned:
Status: Not a bug Package: Online Doc Editor problem
PHP Version: 5.4Git-2012-11-03 (Git) OS: linux debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: abelahcene at gmail dot com
New email:
PHP Version: OS:

 

 [2012-11-03 12:50 UTC] abelahcene at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.echo#refsect1-function.echo-description
---

echo   or print  don t  print spaces and new lines

so echo "hello \n world \n hello again"

is printed in the same line.

same problem with print.


Test script:
---------------
<?php 
echo "hello \n world \n hello again"

?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-04 02:15 UTC] niel dot archer at gmail dot com
Works fine for me using v5.3.13, what version are you using.
Be sure you are using double-quotes, not single-quotes, or the line-feeds will not 
work.
 [2012-11-06 06:01 UTC] rbrunius at gmail dot com
Are you looking at the output with a web browser? If so the "\n" does not cause a 
line break. You need a "<br />".
 [2012-11-06 06:18 UTC] philip@php.net
-Status: Open +Status: Not a bug
 [2012-11-06 06:18 UTC] philip@php.net
Not a bug. And I don't think it's worth mentioning HTML in the documentation 
here.

And you could use nl2br().
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 17:01:30 2025 UTC