Cheking and error on a PHP function

后端 未结 3 850
甜味超标
甜味超标 2020-12-12 05:11

There is a way to check with a \"IF\" if a function fails in php?

Ex.

If (getimagesize($image) returns and error)  {
ec         


        
3条回答
  •  一个人的身影
    2020-12-12 05:38

    Whatever the condition is on an "if" statement (what's inside the parenthesis) will return "true" or "false". If the condition returns "true", the first statement will be executed, otherwise the second statement will get executed.

    You can put this, error_reporting(E_ALL); at the very top of your script, right after your opening php tag, to see what error you get.

    Hope it helps.

    Maybe something like this:

    if the function or statement you run inside the "if" or "else" fails, at least you know which one was it based on the result, and the error_reporting might tell you why it failed.

提交回复
热议问题