note 35842 added to function.system
| From: | morris_hirsch at hotmail dot com | Date: | Tue, 16 Sep 2003 18:49:37 +0000 |
| Subject: | note 35842 added to function.system | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56582@lists.php.net to get a copy of this message | ||
another reason to use shell_exec instead of system is when the result is multiple lines such as grep
or ls
<?php
// this correctly sets answer string to all lines found
//$answer = shell_exec ("grep 'set of color names' *.php ");
//echo "answer = $answer";
// this passes all lines to output (they show on page)
// and sets answer string to the final line
$sys = system ("grep 'set of color names' *.php ");
echo "sys =(($sys))";
?>
here is view/source resulting from system call
setprefs.php:// The standard set of color names is:
setprefs.php:// Most browsers accept a wider set of color names
silly.php: //$answer = shell_exec ("grep 'set of color names' *.php ");
silly.php: $sys = system ("grep 'set of color names' *.php ");
sys =((silly.php: $sys = system ("grep 'set of color names' *.php ");))
and here is view source from using shell_exec instead
answer = setprefs.php:// The standard set of color names is:
setprefs.php:// Most browsers accept a wider set of color names
silly.php: $answer = shell_exec ("grep 'set of color names' *.php ");
silly.php:// $sys = system ("grep 'set of color names' *.php ");
----
Manual Page -- http://www.php.net/manual/en/function.system.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35842
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35842&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35842&report=yes