How to check if a function returns error or not
Permalink
Say you pass the wrong data type to a function such as DateTime::createFromFormat,
You will get an error that stops the script.
Is there a way to instead check if the function returns an error or not then do something based on that?
Kind of how bash "if command" works.
You will get an error that stops the script.
Is there a way to instead check if the function returns an error or not then do something based on that?
Kind of how bash "if command" works.
Some function behaves differently, throwing an exception when they received invalid arguments. In this case you can use a try/catch block: see for instancehttp://3v4l.org/vWmCp
In any case, this kind of questions are not related to concrete5, so you may have better support in that by asking some generic PHP discussion group