zl程序教程

您现在的位置是:首页 >  后端

当前栏目

PHP 命名空间笔记详解编程语言

PHP笔记编程语言 详解 空间 命名
2023-06-13 09:11:50 时间

1.php文件代码如下


?php
//我用这样的命名空间表示处于blog下的article模块
namespace Blog/Article;

class Comment {
function __construct(){ //初始化对象,将初始化值放在括号内
echo初始化1;
}
}

?

2.php文件代码如下


?php
require 1.php;

//调用Blog/Article空间的类
$article_comment = new /Blog/Article/Comment();


/*require 1.php;
use Blog/Article/Comment;
$article_comment = new Comment();*/


/*namespace Blog/Article;

require 1.php;
$article_comment = new Comment();*/
?

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/19047.html

cjavaphp