Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is why languages come with error messages (usually). It won't just crash silently if something goes wrong, it will tell you. So you can make reasonable assumptions about what you think should always be true, and if it's ever not true for some reason, you'll be informed.</p> <p>The following checks are useless, IMO:</p> <ol> <li><code>file_exists</code> - IF the filename is known and you put it there. If the parameter is a variable, then this is OK.</li> <li><code>is_bool</code>, <code>is_int</code>, etc. If you insist on the type being correct, use <code>===</code> for comparison. The only one of these I ever use is <code>is_array</code>.</li> <li><code>function_exists</code> and the like - if you know the file is there, and you put the function in the file, you can safely assume the function exists. Again, there are special cases where this function is useful - yours is not one of them.</li> </ol> <p><code>isset</code> can be useful in some cases, like checking if an array contains a non-null value for a given key, or if a parameter was passed in $_REQUEST. There are other ways of checking that don't involve <code>isset</code>, but that's not my point.</p> <p>If you can reasonably expect your assertions should true all the time, that it would take a data corruption or huge error on your part to make it false, don't bother checking. If something does go wrong once in a million tries, then you can catch the error and fix it for next time. The cost to your code readability is too great otherwise.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload