In my PHP error handler I want to do something like:
if (ini_get('display_errors') IS ON)) {
// show debug info
} else {
// show just "oops!"
}
I’ve look through the docs and stuff, but I can’t really find out what the possible values for display_errors are (such as “on”, 0, “Yes”) and what it does for what value.
What should I put in place of the “IS ON” to reliably read this value?
You can get the string representation of the values through ini_get(), values that
display_errorscan be set to is either,true\false,0\1andOn\Off. But when user’s set theirphp.iniit is more common to use1orOnor to check for ALL cases, you can perform a switch-case
If you prefer the equality comparison approach, notice that
ini_getreturns aStringvalue of1, if you test the returned value withini_getusing the==with theintvalue1, it becomes true. If you use the===it checks if both are equal and of the same type.Stringis not the same type asintso it would returnfalse.Using
ini_get('display_errors')you can check against values like,TRUE,FALSE, andeven
NULL. They will return a boolean value of either0which isfalseand anything other than0evaluates totrue.I saw your comment about a discrepancy so I decided to test it myself, here is what I used
This answer is a bit lengthy, but I hope this is what you need.