PHP shell脚本'echo -ne'怎么样? (Shell Progressbar)

I have a PHP script where I want to show its progess. From this super question and perfect answer How to add a progress bar to a shell script? I tried to emulate the behaviour:

shell_exec("echo -ne '######      30%'");

But nothing gets printed to the screen.

My guess is this is because STDOUT not correct, or I have to echo the echo like?

echo shell_exec("echo -ne '######      30%'");

To use this in a php shell script you don't need to execute any shell commands at all. Just echo the output ending with a

echo "######      30%";

example script:

<?php
for ($i = 0; $i < 100; $i += 5) {
  $bar = str_repeat("#", $i/10);
  echo "$i% $bar ";
  sleep(1);
}
echo "
";
?>

There is a good example for a progress bar in PHP command line interface: http://brian.moonspot.net/php-progress-bar

It is directly done in PHP without system calls.