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);
 
原文地址:https://www.cnblogs.com/kevin-yang123/p/14481682.html