php命名空间

 1     /**
 2     *   demo.php
 3     */
 4     namespace test\add;
 5     class addComputer{
 6         function __construct(){
 7             echo 'test\add\addCompute';
 8         }
 9     }
10     namespace test\del;
11     class delComputer{
12         function __construct(){
13             echo 'test\del\delComputer';
14         }
15     }
16     class useComputer{
17         function __construct(){
18             echo 'test\del\useComputer';
19         }
20     }
21        
22     /**
23     *   demo1.php
24     */
25     include('demo.php');
26     new test\add\addComputer();
27     new test\del\useComputer();
28     new test\del\delComputer();
29        
30     /**
31     *   demo2.php
32     *   应用短名
33     */
34     include('demo.php');
35     use test\add as add;
36     use test\del\delComputer as del;
37     new add\addComputer();
38     new del();
39     new test\del\delComputer();
40        
41     /**
42     *   demo2.php
43     *   autoload
44     */
45     function __autoload($class){
46         echo $class;
47     }
48     use test\add as add;
49     use test\del\delComputer as del;
50     new add\addComputer();            //test\add\addComputer
51     new del();                        //test\del\delComputer
52     new test\del\useComputer();       //test\del\useComputer

 

转载于:https://www.cnblogs.com/yuyufengh/archive/2013/04/05/3000956.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值