PHP CLI application on Debian: why can't I print a line break?

I have a really cryptic problem: I am writing a PHP CLI application running on a debian server. I am connected to the server via SSH, just the usual way. Everything works as usual. Except the following:

echo "My CLI fun\n\n";
echo "Is this.";

      

Outputs on SSH terminal when executing PHP script:

My CLI funIs this.

      

I am really puzzled as I have never had such a problem. bash behaves fine in all other respects. I have already tried to deduce chr(10)

the same problem.

Does anyone have a clue?

+2


a source to share


3 answers


solvable. Sorry for wasting your time. The problem was the php script went through the bash script that called it.



So, for people with the same problem: bash scripts seem to filter the output in some weird way! Try to call the PHP script directly.

+1


a source


Have you tried using a persistent PHP constant:



echo "My CLI fun".PHP_EOL.PHP_EOL; 
echo "Is this."; 

      

+3


a source


You tried...

echo "My CLI fun" . chr(13) . chr(10);
echo "Is this";

      

..

I know this is something like MSWindows, but works on Ubuntu.

0


a source







All Articles