<? $cmd = "echo 'argv <- \"ex_2.r\"; source(argv)' | " . "/usr/bin/R --vanilla --slave"; $handle = popen($cmd, "r"); $ret = ""; do{ $data = fread($handle, 8192); if(strlen($data) == 0){ break; } $ret .= $data; } while(true); pclose($handle); header("Content-type:image/png"); echo $ret; ?>
PHP
echo
R
dev.off.wrap <- function(){ dev.off() invisible() } bitmap(file = "%stdout", type="png256") pie(rep(1, 24), col = rainbow(24)) dev.off.wrap()