Blogger Information
Blog 38
fans 0
comment 1
visits 30714
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
5月8日作业:use 导入空间/别名
1
Original
723 people have browsed it

实例

<?php
//命名空间
namespace one
{
    //导入one\two的命名空间 另命名
    use one\two\Demo as Demo1;


    class Demo
    {
        public $name='小红帽';
    }

    //常量
    const TITLE = '童话故事';
    //add方法
    function add($a,$b)
    {
        return $a+$b;
    }
    //输出Demo
    echo (new Demo)->name;
    //输出two\Demo
    echo (new Demo1)->name;

}

namespace one\two
{


    class Demo
    {
        public $name='小蓝帽';
    }

    const TITLE = '格林童话';

    function add($a,$b)
    {
        return $a+$b;
    }
}

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
  • 1
    2018-03-16 00:39:40