开发者

PHP CLI Application on Debian: why can't I output a line break?

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

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

Outputs on the SSH terminal, when executing the PHP script:

My CLI funIs this.

I am really puzzled as I开发者_StackOverflow社区 have never had such a problem. The bash behaves normal in all other aspects. I already tried to output chr(10) and such, same problem.

Does anybody have a clue?


Have you tried using PHP's OS-sensitive constant:

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


Solved. Sorry for wasting your time. The problem was that the php script was passed through a bash script that called it.

So, for people with the same problem: bash scripts seem to filter the output in some strange ways! Try calling the php script directly.


Have you tried...

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

..?

I know it's kind of a MSWindows thing, but it works on Ubuntu.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜