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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
49 - 7 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC