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 \r
echo "###### 30%\r";
example script:
<?php
for ($i = 0; $i < 100; $i += 5) {
$bar = str_repeat("#", $i/10);
echo "$i% $bar \r";
sleep(1);
}
echo "\n";
?>