How to run external command using php?

Runnning external command in PHP is done by using following method, the PHP exec() command will used to execute the command line statment.

$output = array();
exec(‘dir’, $output);
var_dump($output);

Here exec(‘dir’, $output) will execute the dir console command and store the output in  aPHP variable $output. The output of the dir command is can shown in the screen using var_dump() PHP function.


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: