Home >> Hobbies >> PHP Programming

Hobbies --> PHP Programming

Executing a System Command Using passthru()

Executing system commands can be useful in the right situation.  There are several PHP commands to do this, namely exec, system, and passthru.  The passthru command is useful if you want to display the raw output.  For example, to find out the current directory on the server, use the following code:


<?php
$command = "pwd";
passthru($command);
?>
output --> /home/dirname/public_html 

 


Home >> Hobbies >> PHP Programming

webmaster at vansvault dot org

Last modified: February 20, 2006