现在很多公司企业招聘,直接要求会使用thinkphp框架,或许你更喜欢原生,但是不可以否认框架开发的效率。
好的,让我们来一起学习学习ThinkPHP5.0吧~~
我这边使用ThinkPHP5.0.5完整版作为练习版本~~
下载地址1:http://www.thinkphp.cn/down.html
下载地址2:http://download.csdn.net/detail/iwanghang/9763145 (推荐这里下载,官网下载我失败了,我从别的地方找到的版本)
立即学习“PHP免费学习笔记(深入)”;
入口文件:

配置文件:

数据库配置:

当你在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 = 'iwanghang')
{
echo $name.'<br>';
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('users')->find();
print_r($data);
// $this->aasign('data',$data);
// $this->aasign('name',name);
// return $this->fetch();
return '<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>';
}
}以上就是Android程序员学PHP开发(29)-ThinkPHP5.0(1)初体验-PhpStorm的内容,更多相关内容请关注PHP中文网(www.php.cn)!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号