Home > Backend Development > PHP Tutorial > Recommended resources for Band of Brothers ThinkPHP3.1 basic video tutorial

Recommended resources for Band of Brothers ThinkPHP3.1 basic video tutorial

黄舟
Release: 2023-03-15 16:24:01
Original
1983 people have browsed it

ThinkPHP was born to simplify enterprise-level application development and agile WEB application development. It was first born in early 2006, and was officially renamed ThinkPHP on New Year's Day 2007, and was released under the Apache2 open source agreement. ThinkPHP has been adhering to the simple and practical design principle since its birth. While maintaining excellent performance and minimal code, it also focuses on ease of use. And it has many original functions and features. With the active participation of the community team, it is continuously optimized and improved in terms of ease of use, scalability and performance.

Recommended resources for Band of Brothers ThinkPHP3.1 basic video tutorial

Course playback address: http://www.php.cn/course/383.html

The teacher’s teaching style:

The teacher’s lectures are simple, clear, layer-by-layer analysis, interlocking, rigorous argumentation, rigorous structure, and use the logical power of thinking to attract students’ attention Strength, use reason to control the classroom teaching process. The teaching skills are full of wit. Various teaching methods and techniques are readily available and can be used freely and appropriately without any trace of polishing.

The more difficult points in this video should be: grouping, page jump and ajax:

1. Multi-application configuration skills
2. Use Grouping
3. Page jump
$this->success('Query successful',U('User/test'));
$this->redirect('User/test', '',5,'The page is jumping');
4. Ajax skills

前后台公用公共配置文件:  
  
$ 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);  
    }  
  
}
Copy after login

The above is the detailed content of Recommended resources for Band of Brothers ThinkPHP3.1 basic video tutorial. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template