note 18022 added to function.system

From: Date: Mon, 07 Jan 2002 21:09:35 +0000
Subject: note 18022 added to function.system
Groups: php.notes 
Request: Send a blank email to php-notes+get-24509@lists.php.net to get a copy of this message
system() is messy in that it returns the last line of the output, and it prints it as well. A replacement for system which behaves more like the C library system() call by returning the numeric status code is given below. It is different in that it combines stdout and stderr and only prints them if $hide is set false: function mysystem($command, $hide=true) { if (!($p=popen("($command)2>&1","r"))) return 126; while (!feof($p)) { $l=fgets($p,1000); if (!$hide) print $l; } return pclose($p); } -- http://www.php.net/manual/en/function.system.php http://master.php.net/manage/user-notes.php?action=edit+18022 http://master.php.net/manage/user-notes.php?action=delete+18022 http://master.php.net/manage/user-notes.php?action=reject+18022

« previous php.notes (#24509) next »