登录  /  注册

兄弟连ThinkPHP3.1基础视频教程的资源推荐

黄舟
发布: 2017-08-31 09:54:59
原创
1766人浏览过

thinkphp是为了简化企业级应用开发和敏捷web应用开发而诞生的。最早诞生于2006年初,2007年元旦正式更名为thinkphp,并且遵循apache2开源协议发布。thinkphp从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进。

KNX)%8AD369$RZEYO57Z5(X.png

课程播放地址:http://www.php.cn/course/383.html

该老师讲课风格:

教师讲课深入浅出,条理清楚,层层剖析,环环相扣,论证严密,结构严谨,用思维的逻辑力量吸引学生的注意力,用理智控制课堂教学进程。教学的技巧,充满着机智,各种教学方法、技巧信手拈来,运用自如,恰到好处,并丝毫不带有雕琢的痕迹。

本视频中较为难点的应该是:分组、页面跳转与ajax:

一、多应用配置技巧
二、使用分组
三、页面跳转
$this->success('查询成功',U('User/test'));
$this->redirect('User/test','',5,'页面正在跳');
四、Ajax技巧

前后台公用公共配置文件:  
  
$ pwd  
/cygdrive/c/wamp/www/thinkphp5/Admin/Conf  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5/Admin/Conf  
$ ls  
config.php  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5/Admin/Conf  
$ cat config.php  
<?php  
$arr=include &#39;./config.php&#39;;  
  
$arr2=array(  
  
);  
return  array_merge($arr,$arr2);  
  
  
?>  
  
// 当前目录下的config.php,这个当前是指主入口的路径:  
  
  
$arr=include &#39;./config.php&#39;;  
  
  
  
公用配置文件:  
$ pwd  
/cygdrive/c/wamp/www/thinkphp5  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5  
$ ls -ltr config.php  
-rwxrwx---+ 1 Administrators None 393 五月  9 13:14 config.php  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5  
$ cat config.php  
<?php  
return array(  
        //&#39;配置项&#39;=>&#39;配置值&#39;  
        &#39;TMPL_L_DELIM&#39;=>&#39;<{&#39;,   //配置左定界符  
        &#39;TMPL_R_DELIM&#39;=>&#39;}>&#39;,    //配置右定界符  
        &#39;DB_PREFIX&#39;=>&#39;&#39;,     //设置表前缀  
        &#39;DB_DSN&#39;=>&#39;mysql://root:1234567@192.168.32.79:3306/devops&#39;, //DSN方式配置数据库信息  
        &#39;SHOW_PAGE_TRACE&#39;=>true,//开启页面Trace  
        /* &#39;URL_ROUTER_ON&#39;=>true,  
        &#39;URL_ROUTE_RULES&#39;=>array(  
         &#39;:id/:num&#39;=>&#39;Index/index&#39;,  
         ), */  
);  
?>  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5  
  
  
  
  
  
thinkphp 分组机制:  
  
<?php  
//1.确定应用名称 Home  
  
define(&#39;APP_NAME&#39;,&#39;App&#39;);  
  
//2. 确定应用路径  ./Home 当前目录 index.php的当前目录 前台文件夹  
  
define(&#39;APP_PATH&#39;,&#39;./App/&#39;);  
//开启调试模式  
  
 define(&#39;APP_DEBUG&#39;,true);  
//4.引入核心文件 include 引入的东西错误 代码继续运行  require 出错立即结束  
  
require &#39;./ThinkPHP/ThinkPHP.php&#39;;  
  
?>  
  
  
  
  
&#39;APP_GROUP_LIST&#39; => &#39;Home,Admin&#39;, //项目分组设定  
&#39;DEFAULT_GROUP&#39;  => &#39;Home&#39;, //默认分组  
  
  
  
  
  
在同一个应用下,再分不同的应用:  
  
$ pwd  
/cygdrive/c/wamp/www/thinkphp6/App/Lib/Action  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp6/App/Lib/Action  
$ ls  
Admin  Home  IndexAction.class.php  
  
  
整个应用叫app应用:  
  
<?php  
//1.确定应用名称 Home  
  
define(&#39;APP_NAME&#39;,&#39;App&#39;);  
  
//2. 确定应用路径  ./Home 当前目录 index.php的当前目录 前台文件夹  
  
define(&#39;APP_PATH&#39;,&#39;./App/&#39;);  
//开启调试模式  
  
 define(&#39;APP_DEBUG&#39;,true);  
//4.引入核心文件 include 引入的东西错误 代码继续运行  require 出错立即结束  
  
require &#39;./ThinkPHP/ThinkPHP.php&#39;;  
  
?>  
  
  
  
  
  
  
推荐使用分应用的方式,而不是分组  
  
  
分应用情况下的访问方式,多应用配置技巧:  
  
  
$ pwd  
/cygdrive/c/wamp/www/thinkphp5  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5  
$ ls  
Admin  admin.php  config.php  Home  index.php  ThinkPHP  
  
  
Home前台应用文件夹:  
  
Admin后台应用文件夹:  
  
http://localhost/thinkphp5/admin.php  
  
http://localhost/thinkphp5/index.php  
  
  
  
//页面跳转:  
  
<?php  
// 本类由系统自动生成,仅供测试用途  
class IndexAction extends Action {  
    public function index(){  
    echo "come in Home!";  
    $user=M(&#39;user&#39;);  
    $arr=$user->select();  
    dump($arr);  
    //分配给前台,表示为list   
    $this->assign(&#39;list&#39;,&#39;$arr&#39;);  
    $this->display();  
    }  
}  
  
  
  
前端页面:  
<!doctype html>  
<html lang="en">  
 <head>  
  <meta charset="UTF-8">  
  <meta name="Generator" content="EditPlus®">  
  <meta name="Author" content="">  
  <meta name="Keywords" content="">  
  <meta name="Description" content="">  
  <title>Document</title>  
 </head>  
 <body>  
    
  <table border=&#39;1&#39; width=&#39;500&#39;>  
  <foreach name=&#39;list&#39; item=&#39;vo&#39;>  
  
  <tr><td><{$vo.username}></td></tr>  
  
  </foreach>  
  
  </table>  
 </body>  
</html>  
  
  
//超链接:  
  
<!doctype html>  
<html lang="en">  
 <head>  
  <meta charset="UTF-8">  
  <meta name="Generator" content="EditPlus®">  
  <meta name="Author" content="">  
  <meta name="Keywords" content="">  
  <meta name="Description" content="">  
  <title>Document</title>  
 </head>  
 <body>  
    
  <table border=&#39;1&#39; width=&#39;500&#39;>  
  <foreach name=&#39;list&#39; item=&#39;vo&#39;>  
  
  <tr><td><a href="__URL__/info?id=<{$vo.id}>"><{$vo.username}></a></td></tr>  
  
  </foreach>  
  
  </table>  
 </body>  
</html>  
  
  
  
  
<?php  
// 本类由系统自动生成,仅供测试用途  
class IndexAction extends Action {  
    public function index(){  
    echo "come in Home!";  
    $user=M(&#39;user&#39;);  
    $arr=$user->select();  
    dump($arr);  
    //分配给前台,表示为list   
    $this->assign(&#39;list&#39;,$arr);  
    $this->display();  
    }  
      
    public function info(){  
        $id=$_GET[&#39;id&#39;];  
        $user=M(&#39;user&#39;);  
        $arr=$user->find($id);  
        dump($arr);  
        if ($arr){  
            $this->success(&#39;index&#39;);  
        }  
        else {  
            //失败后自动跳转到上一页  
            $this->error(&#39;查询失败&#39;);  
        }  
        $this->assign(&#39;list&#39;,$arr);  
        $this->display();  
    }  
}  
  
  
//redirect 跳转:  
  
<?php  
// 本类由系统自动生成,仅供测试用途  
class IndexAction extends Action {  
    public function index(){  
    echo "come in Home!";  
    $user=M(&#39;user&#39;);  
    $arr=$user->select();  
    dump($arr);  
    //分配给前台,表示为list   
    $this->assign(&#39;list&#39;,$arr);  
    $this->display();  
    }  
      
    public function info(){  
        $id=$_GET[&#39;id&#39;];  
        $user=M(&#39;user&#39;);  
        $arr=$user->find(100);  
        dump($arr);  
        if ($arr){  
            $this->success(&#39;index&#39;);  
        }  
        else {  
            //失败后自动跳转到上一页  
            $this->redirect(&#39;User/index&#39;);  
        }  
        $this->assign(&#39;list&#39;,$arr);  
        $this->display();  
    }  
}  
  
  
跳转到:  
http://localhost/thinkphp5/index.php/User/index  
  
User/index 页面  
  
  
  
Ajax 技巧:  
  
  
  
在框架里面,脚本都是被方法所取代  
  
  
<!doctype html>  
<html lang="en">  
 <head>  
  <meta charset="UTF-8">  
  <meta name="Generator" content="EditPlus®">  
  <meta name="Author" content="">  
  <meta name="Keywords" content="">  
  <meta name="Description" content="">  
  <title>Document</title>  
  <script src="__PUBLIC__/Js/jquery.js"></script>  
  <script>  
  $(function(){  
  $(&#39;button&#39;).bind(&#39;click&#39;,function(){  
   
    $.get(&#39;__URL__/getAjax&#39;,function(jdata){  
    <!--alert (JSON.stringify(data));-->  
    if (jdata.status==1){  
    alert(jdata.data);  
    }  
  });  
  });  
     
   });  
  
    
  </script>  
 </head>  
 <body>  
   <div style=&#39;height:50px;background:yellow&#39; id=&#39;did&#39;></div>  
   <button>点击</button>  
   <script>  
     document.write(new Date());  
     </script>  
 </body>  
</html>  
  
  
<?php  
class IndexAction extends Action {  
      
    public function index(){  
        $this->display();  
    }  
      
    public function getAjax(){  
        //echo &#39;aaaaaaa&#39;;  
        $this->ajaxReturn(&#39;这里是数据&#39;,&#39;信息1&#39;,1);  
    }  
  
}
登录后复制

以上就是兄弟连ThinkPHP3.1基础视频教程的资源推荐的详细内容,更多请关注php中文网其它相关文章!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号