简体   繁体   English

print_r不会转到下一行

[英]print_r doesn't go to next line

I'm trying to run a bash script in php; 我正在尝试在php中运行bash脚本; also, i want to see the log of the bash script. 另外,我想查看bash脚本的日志。 So, my php file looks like something like this: 因此,我的php文件看起来像这样:

<?php
    $message=shell_exec("/var/www/html/judge/uploads/MyScript.sh 2>&1");
    print_r($message);
?>

"Myscript.sh" is this : “ Myscript.sh”是这样的:

    #!/bin/bash
    printf "MyScript \nran \nsuccesfully"

And the output is: 输出为:

MyScript ran successfully 

But i want the output to be something like this: 但是我希望输出是这样的:

MyScript
ran
successfully

What should i do? 我该怎么办?

Posting as a community wiki; 作为社区Wiki发布; I don't want rep from this. 我不要这个代表。

As per my comment: 根据我的评论:

If you view your HTML source, you will see the line breaks are indeed there. 如果您查看HTML源代码,则会看到换行符确实存在。 If you want to see them on different lines "on screen", you need to use either <br> or nl2br() . 如果要在屏幕上的不同行上查看它们,则需要使用<br>nl2br()

Reference: 参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM