<?php
echo "passthru()" . PHP_EOL;
passthru("ls");
echo PHP_EOL;
echo "exec()" . PHP_EOL;
$output = '';
$last_line = exec("ls", $output);
echo implode(PHP_EOL, $output) . PHP_EOL;
echo PHP_EOL;
echo "shell_exec()" . PHP_EOL;
echo shell_exec("ls");
echo PHP_EOL;
echo "system()" . PHP_EOL;
$last_line = system("ls");
echo PHP_EOL;
echo "popen()" . PHP_EOL;
$p = popen("ls", "r");
while(!feof($p))
{
echo fread($p, 1024);
}
pclose($p);
echo PHP_EOL;
echo "proc_open()" . PHP_EOL;
$pipe_descriptions = array(array("pipe", "r"), array("pipe", "w"), array("pipe", "r"));
$p = proc_open("ls", $pipe_descriptions, $pipes);
fclose($pipes[0]);
while(!feof($pipes[1]))
{
echo fread($pipes[1], 1024);
}
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($p);
Comments