note 94262 modified in function.system by thiago
| From: | thiago@php.net | Date: | Mon, 26 Oct 2009 13:40:50 +0000 |
| Subject: | note 94262 modified in function.system by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162104@lists.php.net to get a copy of this message | ||
If you don't want the output of your command echoed to STDOUT while using PHP for scripting
(Unix/CLI) use exec() instead of system().
May apply to CGI versions, YMMV.
<?php
$cmd = "date";
$output = system($cmd);
printf("System Output: $output\n");
exec($cmd, $results);
printf("Exec Output: {$results[0]}\n");
/*
Output:
Mon Oct 26 19:30:08 EST 2009
System Output: Mon Oct 26 19:30:08 EST 2009
Exec Output: Mon Oct 26 19:30:08 EST 2009
*/
?>
--was--
If you don't want the output of your command echoed to STDOUT while using PHP for scripting
(Unix/CLI) use exec() instead of system().
May apply to CGI versions, YMMV.
<?
$cmd = "date";
$output = system($cmd);
printf("System Output: $output\n");
exec($cmd, $results);
printf("Exec Output: {$results[0]}\n");
/*
Output:
Mon Oct 26 19:30:08 EST 2009
System Output: Mon Oct 26 19:30:08 EST 2009
Exec Output: Mon Oct 26 19:30:08 EST 2009
*/
?>
http://php.net/manual/en/function.system.php