ThinkPHP学习之windows下安装并运行Hello World

来源:互联网 发布:sql注入攻击步骤 编辑:程序博客网 时间:2024/06/05 07:47

1.在php的www目录下,创建项目文件夹(如创建名为think的文件夹)

2.将thinkPHP完整包解压到think目录下。

3.建立单入口文件,在think目录下,创建名为index.php的文件,文件中需要定义入戏内容:

1)项目名称,如Index

         2)项目路径

         3)引入ThinkPHP.php核心运行文件

完整代码如下:

<?php//单入口文件define('APP_NAME','Index'); //项目名称(项目指前台项目)define('APP_PATH','./Index/'); //项目路径(通常与项目名称一致)        define('RUNTIME_PATH','./Index/Temp/');//定义编译目录位置        include './ThinkPHP/ThinkPHP.php';//引入ThinkPHP.php核心运行文件?>
4.在浏览器地址栏敲入:localhost/think/index.php。出现笑脸则安装成功。

5.找到/think/Index/Lib/Action/IndexAction.class.php文件,该文件为MVC中的控制器,该文件内容如下:

<span style="font-size:18px;"><?php// 本类由系统自动生成,仅供测试用途class IndexAction extends Action {    public function index(){$this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background:                      #fff; font-family: "微软雅黑"; color: #333;} h1{ font-size: 100px; font-weight: normal; margin                     -bottom: 12px; } p{ line-height: 1.8em; font-size: 36px }</style><div style="padding: 24px 48p                      < span style="white-space:pre"></span> x;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p></div                      ><script type="text/javascript" src="ht<span style="white-space:pre"></span>      tp://tajs.q                      q.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');    }}</span>
6.更改Index函数的函数体,修改成echo ‘Hello World’;

7.重新在浏览器中访问index.php,若显示Hello World,则安装成功。


0 0