php namespace与use的有关问题

WBOY
Release: 2016-06-13 11:50:26
Original
1008 people have browsed it

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(); 只需取命名空间的最后一节即可
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template