if(is_arrray($arr)
{
//code...
}
if(\is_array($arr)
{
//code..
}
这两个条件得到的结果是相同的。但是,确切地说,它们之间有什么区别呢?
if(is_arrray($arr)
{
//code...
}
if(\is_array($arr)
{
//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";
}
?>
\is_array
的意思是:给我全局命名空间中的is_array
函数。而\Eldhose\is_array
可能是在Eldhose
命名空间下创建的另一个函数。 - Savas Vedova