PHP Developers Cookbook (2nd Edition)
Technique
Use the passthru () function, which will print the results of your shell command directly to standard output: <?php passthru('date'); ?> Comments
If you simply need to execute a command and display the output to the browser, use the passthru() function, which frees you from worrying about the intermediate steps. (This is similar to fpassthru() and readfile() , which act on files.)
Gotcha I stressed this in the previous recipe, but I will also stress it here: Always use the EscapeShellCmd() function when accepting data from your users. In that way, harmful shell characters are escaped. passthru(EscapeShellCmd($submitted_data));
|