how to hide system() output
use ob_start(); before and ob_clean(); after calling it
http://sandbox.phpcode.eu/g/850a3.php
<?php
ob_start();
echo '<pre>';
$last_line = system('ls');
ob_clean();
echo 'nothing returned!';
?>
The documentation for system() specifically says:
Execute an external program and display the output
On that page are listed alternatives. If you use the exec function instead, it will only execute the commands without displaying any output.
Example:
<?php
echo "Hello, ";
system("ls -l");
echo "world!\n";
?>
will display the output of system
:
$ php -q foo.php
Hello, total 1
-rw-r--r-- 1 bar domain users 59 Jul 15 16:10 foo.php
world!
while using exec
will not display any output:
<?php
echo "Hello, ";
exec("ls -l");
echo "world!\n";
?>
$ php -q foo.php
Hello, world!