Home  >  Article  >  Backend Development  >  怎样将print_r结果输出的txt文件里去?解决方案

怎样将print_r结果输出的txt文件里去?解决方案

WBOY
WBOYOriginal
2016-06-13 13:37:141064browse

怎样将print_r结果输出的txt文件里去?
怎样将print_r结果输出的txt文件里去?


------解决方案--------------------
print_r

可以带第二个参数,翻手册
------解决方案--------------------
$s = print_r($var, true);
file_put_contents('arr.txt', $s);


------解决方案--------------------

PHP code
<?php ob_start();
// ... do something
// 输出要保存到记事本的内容
// print_r(array('hello', 'wolrd'));
$data = ob_get_contents();
ob_end_clean();
$flink = fopen('arr.txt', 'w');
fwrite($flink, $data);
?> <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn