我收到此特别警告:
Warning: Division by zero in C:\xampp\htdocs\OnlineQuiz\Resultpage.php on line 98
我用了除法表达式。像这样:
Ratio = Correct answers/Attempted questions
如果两个都为0,我会得到警告。但是我不要这个。我只想要一条消息,而不是此错误。如何处理呢?
最佳答案
通过在操作前添加@
符号来忽略错误:
Ratio = @Correct answers/Attempted questions
http://php.net/manual/en/language.operators.errorcontrol.php
关于php - 如何使用异常处理或错误处理停止页面以显示特定警告(请参阅详细信息)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32133381/