Shayan Peyghambari Shayan Peyghambari - 1 year ago 108
PHP Question

print_r doesn't go to next line

I'm trying to run a bash script in php; also, i want to see the log of the bash script. So, my php file looks like something like this:

$message=shell_exec("/var/www/html/judge/uploads/ 2>&1");

"" is this :

printf "MyScript \nran \nsuccesfully"

And the output is:

MyScript ran successfully

But i want the output to be something like this:


What should i do?

Answer Source

Posting as a community 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. If you want to see them on different lines "on screen", you need to use either <br> or nl2br().


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download