I have been rooting around with PHP for a while now but I've stumbled across something that I can't make heads or tails of. It is from a post that I found on here (that I believe has been locked) and I understand most of the solution, but there's just one part that I'm confused on.
if ( ( $number & $error_number ) == $number )
{
$error_description[ ] = $description;
}
I'm not quite sure what is being checked here. Any help is appreciated.
((Full code))
<?php
$error_number = 22527; //could also use ini_get('error_reporting')
$error_description = array( );
$error_codes = array(
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
E_ALL => "E_ALL"
);
foreach( $error_codes as $number => $description )
{
if ( ( $number & $error_number ) == $number )
{
$error_description[ ] = $description;
}
}
echo sprintf(
"error number %d corresponds to:<br>\n%s",
$error_number,
implode( " | ", $error_description )
);
?>
I understand that the key's in the array are predefined PHP constants, but I'm not sure how that last if statement is working/what it's evaluating.