//php调用graphviz的方法
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
header ("Content-type: image/gif");
//需要手动建立文件夹和文件
$filename = 'tmp/domain.txt';
//graphviz程序
$somecontent = "digraph G {a->b->c->a}";
if (!$handle = fopen($filename, 'w')) {
echo "cannot open $filename";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "cannot write to $filename";
exit;
}
fclose($handle);
//执行程序
passthru("D:/graphviz-2.38/release/bin/dot -Tpng $filename");
//passthru("cat $filename | dot -Tpng");
?>
运行程序后会生成一张图片