在php5.3之后,php像c++那样新 命名空间。
1、在同一个文件中不能实例化同一个名字相同的类和同时包含两个不同目录下的相同文件,中包含相同的函数和常量。为了解决这个问题,因此引入了命名空间。
2、引入命名空间解决了一下三种重名:
1)类
2)函数
3)常量
解决与函数重名的问题
<?php namespace Index; function var_dump($data) { echo 11111; } var_dump(1);<span style="white-space:pre"> </span>//在命名空间中使用自定义的var_dump var_dump(100);<span style="white-space:pre"> </span>//使用系统的var_dump()函数 ?>