php run sh script code example

Example 1: execute script php command line

php php_file.php
// or
php php_file.php > result_file.txt // to display the result of echoes or dumps

Example 2: php download script

<?php
/*Actual filename = 'attachment.zip' (Unknown to the viewers).
When downloaded to be saved as 'mydownload.zip'.
*/
$filename='mydownload.zip';
@header("Content-type: application/zip");
@header("Content-Disposition: attachment; filename=$filename");
echo file_get_contents('attachment.zip');
?>

Tags:

Html Example