php namespace与use的问题
/test文件夹下建立C.php文件,内容
namespace Test\Driver;
class C
{
function test()
{
echo "c";
}
}
?>
/下建立test.php文件,内容
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
无标题文档
include "test/C.php";
use Test\Driver;
$c=new C();
$c->test();
echo "
";
?>
运行错误:
( ! ) SCREAM: Error suppression ignored for
( ! ) Fatal error: Class 'C' not found in E:\hongyunlai\thinkphp32\test.php on line 14
Call Stack
# Time Memory Function Location
1 0.0006 247520 {main}( ) ..\test.php:0
------解决方案--------------------你的命名空间是 Test\
Driver$c=new
Driver\C(); 只需取命名空间的最后一节即可