Difference between 'is_array' and '\is_array'

php

Solution

When you use namespace you can override local functions in you namespace, when you use \ you are calling to the global one.

You can read more about in namespaces.fallback

This is a little example extracted from php.net:

<?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";
}
?>

Problem

``` if(is_arrray($arr) { //code... } if(\is_array($arr) { //code.. } ``` The two conditions gives same result. But, exactly, what is the difference?

Original source