作为一个刚刚接触世界上最好的语言php的新手,前端js可以直接console.log调试,在调试后端rpc的类半天找不到打印输出的方法,普通的print和echo既不能输出到页面也不能输出到文件,痛苦了半天,从网上搜罗了一下亲测好用的语句。


//输出变量或数组到文件$fp=fopen('./a.txt','a+b');fwrite($fp,print_r($content,true));fclose($fp);//打印单个变量到文件error_log($file,3,"/tmp/php_3.log");//输出对象到文件file_put_contents("/tmp/qujun_php2.log",var_export($objects,true),FILE_APPEND);