note 129012 added to function.proc-open
| From: | mamedul dot github dot io at main dot php dot net | Date: | Mon, 06 Nov 2023 23:18:47 +0000 |
| Subject: | note 129012 added to function.proc-open | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220968@lists.php.net to get a copy of this message | ||
Cross function solutions for execute command using PHP-
function php_exec( $cmd ){
if( function_exists('exec') ){
$output = array();
$return_var = 0;
exec($cmd, $output, $return_var);
return implode( " ", array_values($output) );
}else if( function_exists('shell_exec') ){
return shell_exec($cmd);
}else if( function_exists('system') ){
$return_var = 0;
return system($cmd, $return_var);
}else if( function_exists('passthru') ){
$return_var = 0;
ob_start();
passthru($cmd, $return_var);
$output = ob_get_contents();
ob_end_clean(); //Use this instead of ob_flush()
return $output;
}else if( function_exists('proc_open') ){
$proc=proc_open($cmd,
array(
array("pipe","r"),
array("pipe","w"),
array("pipe","w")
),
$pipes);
return stream_get_contents($pipes[1]);
}else{
return "@PHP_COMMAND_NOT_SUPPORT";
}
}
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 37.111.223.98)
----
Manual Page -- https://php.net/manual/en/function.proc-open.php
Edit -- https://main.php.net/note/edit/129012
Del: integrated -- https://main.php.net/note/delete/129012/integrated
Del: useless -- https://main.php.net/note/delete/129012/useless
Del: bad code -- https://main.php.net/note/delete/129012/bad+code
Del: spam -- https://main.php.net/note/delete/129012/spam
Del: non-english -- https://main.php.net/note/delete/129012/non-english
Del: in docs -- https://main.php.net/note/delete/129012/in+docs
Del: other reasons-- https://main.php.net/note/delete/129012
Reject -- https://main.php.net/note/reject/129012
Search -- https://main.php.net/manage/user-notes.php