php开发中抛错记录

<?php
   try {
           //项目
       $this->createProduct($listing);
        } 
catch (\Exception $e) { if (env('APP_ENV') != 'production') {//根据环境显示对应抛错 throw new \Exception("listingId :" . $listingId . "上传出错" . $e->getMessage() . "---file---" . $e->getFile() . '---line---' . $e->getLine()); } else { throw new \Exception("listingId :" . $listingId . "上传出错" . $e->getMessage()); } }
$e->getMessage()-》显示错误信息
$e->getLine()-》显示错误行号
$e->getFile()-》显示错误文件
记录数据,写入文件
file_put_contents('1.txt',$v_result.PHP_EOL, FILE_APPEND);
 

 

posted on 2021-03-04 17:26  kevin_yang123  阅读(19)  评论(0编辑  收藏  举报