This is a silly question, but I can’t seem to wrap my head around the bit mask testing associated with completing this:
Given I create a bunch of generalized functions to extend PHP’s function base:
/**
*
* @param string $path
* @return array
*/
function load_array($path){
$path = path_file($path);
if(null === $path){
// trigger error when appropriate
return array();
}
return ((Array) require($path));
}
path_file() is another function in the library, just assume it to be realpath()
What I’d like to do, is trigger errors according to the current running environment’s reporting level. Given this would be a notice, should I simply test:
if(error_reporting() <= E_USER_NOTICE){ /***/ }
That doesn’t seem right.
would only trigger if the E_USER_NOTICE flag has been enabled in error_reporting, using the bit-wise AND operation.
If you pretend that the error_reporting flag is only 8 bits, and the USER_NOTICE flag is at bit 4, then you’re doing: