How to run an external command using PHP at windows which will not display the output of external command on screen?
I'll suggest you to use exec() function of PHP. This will be helpful when you are using Windows OS. Let say you are running the windows DIR command from your PHP script, and you don't want to show the output on screen.
For this example, the exec() function takes the command as parameter, and the output array as parameter. And after executing the command from php, it returns the output inside your output array.
Inside the example, I have initialized the array as empty. It is always better to do like this while using exec() function. Otherwise it will append the new values after previously one.
I'll suggest you to use exec() function of PHP. This will be helpful when you are using Windows OS. Let say you are running the windows DIR command from your PHP script, and you don't want to show the output on screen.
For this example, the exec() function takes the command as parameter, and the output array as parameter. And after executing the command from php, it returns the output inside your output array.
$output = array();
exec('dir', $output);
var_dump($output);
Inside the example, I have initialized the array as empty. It is always better to do like this while using exec() function. Otherwise it will append the new values after previously one.
Comments