Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I echo in PHP without carriage returns?

Whenever I do an echo in PHP, I get two extra carriage returns. For example:

<?php
  echo 'abc';
?>

yields abc[cr][cr]. If I copy my script to a different server, I even get [cr]abc[cr][cr].

How do I force PHP to echo only my string 'abc' and not the carriage returns?

like image 773
Mark Avatar asked Dec 06 '12 23:12

Mark


1 Answers

echo doesn't append a \n in PHP.

You may want to drop the closing ?> though, then you guarantee you won't have any trailing output.

like image 89
alex Avatar answered Oct 06 '22 00:10

alex