全新编译了php 5.5.10,没有安装apache,想查看一下php.ini在什么位置。
=>那就,输出phpinfo()
终端输出来没有换行,简直就不是人读的。
=>那就,输出到文件
终端执行 $ php w_phpinfo.php
<?php
#文件w_phpinfo.php
$myfile = fopen("result.txt", "w") or die("Unable to open file!");
$txt = phpinfo();
fwrite($myfile, $txt);
fclose($myfile);
嘿,phpinfo还是输出到了终端。result.txt里只有1。
=>那就百度下。打开php的输出缓冲区。
终端重新执行 $ php w_phpinfo.php
<?php
#文件w_phpinfo.php
$myfile = fopen("result.txt", "w") or die("Unable to open file!");
# 打开输出缓冲区
# 所有的输出信息不直接发送到浏览器,而是保存在输出缓冲区
ob_start();
phpinfo();
$txt = ob_get_contents();
ob_end_clean();
fwrite($myfile, $txt);
fclose($myfile);
问题被solved