ThinkPHP3.2.2:記錄一下第一個例子的運行過程

來源:互聯網
上載者:User

標籤:http   使用   os   檔案   資料   io   

     初次學習php架構,查了一下,據說laravel市場佔有最高,但是根本裝不了啊。需要cmd下用https方式進行下載,各種帆檣軟體都用上了,根本沒法用,坑死人了。由百度一下,國內的php架構據說thinkPHP熱度很高,從ThinkPHP主站http://www.thinkphp.cn/看了半天教程也沒看懂,自己摸索吧。記錄一下第一個例子的運行過程,防止以後忘記。

     1、安裝WAMPServer,到D:\wamp\。

 

     2、下載ThinkPHP3.2.2核心版。解壓縮後,放到D:\wamp\www\MyWeb\。開啟瀏覽器,輸入網址:http://localhost/MyWeb/

顯示:

:)

歡迎使用 ThinkPHP!

[ 您現在訪問的是Home模組的Index控制器 ]

 

     3、在mysql的thinkphp資料庫中建表並插入資料,用wamp內建的phpmyadmin運行sql:

 

CREATE TABLE IF NOT EXISTS `think_data` (

  `id` int(8) unsigned NOT NULL AUTO_INCREMENT,

  `data` varchar(255) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

INSERT INTO `think_data` (`id`, `data`) VALUES

(1, ‘thinkphp‘),

(2, ‘php‘),

(3, ‘framework‘);

 

    4、修改資料庫配置參數,開啟:D:\wamp\www\MyWeb\Application\Common\Conf\config.php:

 

<?php

return array(

//‘配置項‘=>‘配置值‘

// 添加資料庫配置資訊

‘DB_TYPE‘   => ‘mysql‘, // 資料庫類型

‘DB_HOST‘   => ‘localhost‘, // 伺服器位址

‘DB_NAME‘   => ‘thinkphp‘, // 資料庫名

‘DB_USER‘   => ‘root‘, // 使用者名稱

‘DB_PWD‘    => ‘‘, // 密碼

‘DB_PORT‘   => 3306, // 連接埠

‘DB_PREFIX‘ => ‘think_‘, // 資料庫表首碼

);

 

    5、修改 D:\wamp\www\MyWeb\Application\Home\Controller\IndexController.class.php:

<?php

namespace Home\Controller;

use Think\Controller;

class IndexController extends Controller {

    public function index(){

 

        $Data = M(‘Data‘); // 執行個體化Data資料模型

        $this->data = $Data->select();

        $this->display();

 

}

}

 

    6、檔案夾D:\wamp\www\MyWeb\Application\Home\View下建立檔案夾 Index ,然後建檔案 index.html:

<html>

 <head>

   <title>Select Data</title>

 </head>

 <body>

    <volist name="data" id="vo">

    {$vo.id}--{$vo.data}<br/>

    </volist>

 </body>

</html> 

 

    好了到此大功告成。再次瀏覽 http://localhost/MyWeb/:

顯示:

1--thinkphp

2--php

3--framework

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.