方法: function output($tip, $fileName = 'success'){ $document = $_SERVER['DOCUMENT_ROOT']; $newPath = '/uploads/'; $filePaht = $document. $newPath; if (!is_dir($filePaht)) { mkdir($filePaht, 0777, true); } $newFileName = $fileName. '.txt'; $handle=fopen($filePaht. '/'. $newFileName,"a"); fwrite($handle,"\n-------------------------------------------\n"); fwrite($handle,$tip); fwrite($handle,"\n-------------------------------------------\n"); fclose($handle);}
调用:
tip = '测试';
output($tip);
var_dump写入:
ob_start();var_dump($model->errors, $v);$result = ob_get_clean();$this->output($result,'error');
转载于:https://www.cnblogs.com/aifengguo/p/7003142.html