doutu6616 2013-10-17 09:46
浏览 36
已采纳

在PHP中退出()返回行号

If I have this code in PHP :

if($statement == 'false') {
   return 0;
   exit();
}

As you know, exit() will stop the script from running. Is it possible to return the line number of where the exit() runs?

So it'll return exit() on line 3 (Based on above code)

Thank you!

  • 写回答

2条回答 默认 最新

  • duanmei1536 2013-10-17 09:49
    关注

    PHP has a constant called __LINE__ that outputs the current line in your script. You can also pass a message to exit(), so you can simply combine the two:

    exit('Terminated on line ' . __LINE__);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?