首页  >  文章  >  后端开发  >  Android程序员学PHP开发(29)-ThinkPHP5.0(1)初体验-PhpStorm

Android程序员学PHP开发(29)-ThinkPHP5.0(1)初体验-PhpStorm

黄舟
黄舟原创
2017-03-03 10:01:541555浏览

现在很多公司企业招聘,直接要求会使用thinkPhp框架,或许你更喜欢原生,但是不可以否认框架开发的效率。

好的,让我们来一起学习学习ThinkPHP5.0吧~~

我这边使用ThinkPHP5.0.5完整版作为练习版本~~

下载地址1:http://www.thinkphp.cn/down.html

下载地址2:http://download.csdn.net/detail/iwanghang/9763145   (推荐这里下载,官网下载我失败了,我从别的地方找到的版本)

入口文件:


配置文件:


数据库配置:



当你在database.php配置好你的数据库信息后,就可以在\application\index\controller\index.php中进行数据库操作,参考下面的代码:

(被注释的代码,看不懂没有关系,我们下一篇博文继续学习~)

<?php
/**
 * namespace 命名空间
 */
namespace app\index\controller;
use think\Controller;
use think\Db;

class Index extends Controller
{
    public function index($name = &#39;iwanghang&#39;)
    {
        echo $name.&#39;<br>&#39;;

        print_r($this->request->param());

        // http://www.php.cn/:8888/myPhpDemo/ThinkPhp5.0.5/ThinkPHP_full_v5.0.5/public/index/index/index/aa/11/bb/22/cc/33
        // 上面的连接的打印结果:Array ( [aa] => 11 [bb] => 22 [cc] => 33 )

        /**
         * 查询users表信息并打印
         */
        $data = Db::name(&#39;users&#39;)->find();
        print_r($data);
//        $this->aasign(&#39;data&#39;,$data);
//        $this->aasign(&#39;name&#39;,name);
//        return $this->fetch();

        return &#39;<style type="text/css">
        *{ padding: 0; margin: 0; } 
        .think_default_text{ padding: 4px 48px;} 
        a{color:#2E5CD5;cursor: pointer;text-decoration: none} 
        a:hover{text-decoration:underline; } 
        body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; 
        color: #333;font-size:18px} 
        h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } 
        p{ line-height: 1.6em; font-size: 42px }
        </style>
        <p style="padding: 24px 48px;"> <h1>:)</h1>
        <p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span>
        </p>
        <span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></p>
        <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8">
        </script>
        <script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js">
        </script>
        <thinkad id="ad_bd568ce7058a1091">
        </thinkad>&#39;;
    }
}

以上就是Android程序员学PHP开发(29)-ThinkPHP5.0(1)初体验-PhpStorm的内容,更多相关内容请关注PHP中文网(www.php.cn)!



声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn