在前2篇命名空间的博文基础上,我们来看一下,命名空间、公共空间 与 thinkphp5..0之间的关系:
首先我们找到index的控制器(controller),
\application\index\controller\Index.php,
修一下,修改后的Index.php:
<?php
namespace app\index\controller;
use think\Controller;
class Index extends Controller
{
public function index(){
return $this->fetch();
}
}然后我们手动创建下面2个文件夹view和index,并创建用于控制index视图的index.html,
立即学习“PHP免费学习笔记(深入)”;
\application\index\view\index\index.html,
创建好的index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>iwanghang
</head>
<body>
</body>
</html>\public\index.php,没有做任何修改,我们运行一下,打印结果是iwanghang
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://www.php.cn/ All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.php.cn/ )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
// 定义应用目录
define('APP_PATH', __DIR__ . '/../application/');
// 加载框架引导文件
require __DIR__ . '/../thinkphp/start.php'; 以上就是PHP开发(33)-ThinkPHP5.0(5)命名空间与TP5-PhpStorm的内容,更多相关内容请关注PHP中文网(www.php.cn)!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号