Answer the question
In order to leave comments, you need to log in
PHP Application Architecture - "Right" Mistakes
Hello! There is an application in php. I have a class with a method
String find(String string)He, with the help of the received string, somehow searches for the file and returns the path. Quite often a situation may arise when the file is not found. What is the correct way to return such an error?
Answer the question
In order to leave comments, you need to log in
If the method is called frequently, and the absence of the file is not critical, then return false.
Exceptions are still better to save for emergencies, and null - you can return it,
but false, IMHO, is more informative and more convenient for further use.
By the way, here's a cheat
sheet for PHP: FALSE, NULL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question