Saturday, February 7, 2009

Accessing command line from PHP code

It is sometimes necessary (or easier) to execute command line commands from within PHP code, in this post I will show an example of such usage. If you only need an ├╝ber-basic example, here it is:


$thisf = $_SERVER['SCRIPT_NAME'];
$thisf newname.php`;


This little piece of code will copy the running script to newfile.php. If you're not satisfied yet, keep reading.