I'm using PHP 7.2.1
Consider below code :
<?php
namespace A\B\C;
const E_ERROR = 45;
function strlen($str)
{
return strlen($str) - 1;
}
echo E_ERROR, "\n"; // prints "45"
echo INI_ALL, "\n"; // prints "7" - falls back to global INI_ALL
echo strlen('hi'), "\n"; // prints "1"
if (is_array('hi')) { // prints "is not array"
echo "is array\n";
} else {
echo "is not array\n";
}
?>
Output :
45
7
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in ... on line 7
As per my knowledge, PHP will fall back to global function if a namespaced function does not exist.
Then why I am getting Fatal error here?
Also, is the fatal error I've received mean that the program is running into infinite loop? If yes, how? If no, what's the exact meaning of this fatal error?