zoukankan      html  css  js  c++  java
  • ThinkPHP的运行流程-1

    我在indexLibAction目录下新建了一个ShowAction.class.php文件。ps:该目录是控制器的目录。

    然后这个文件中继承了action这个类。代码如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?php
    class ShowAction extends Action
    {
        public function abc(){
            echo "这是一个测试<br />";
        }
    }
     
     ?>

      现在要访问这个页面,就要在url处输入:http://127.0.0.1/index.php?m=show&a=abc

    来看一下究竟为何会是这样。

    在网站的根目录新建了一个2.php。

    内容为:

    1
    2
    3
    4
    5
    <?php
    echo "<pre>";
    print_r($_GET);
     
     ?>

    不传入任何参数的时候是一个空的数组,会输出如下效果:

    Array
    (
    )

    传参数时就会酱紫,url:http://127.0.0.1/2.php?a=xishaonian&b=helloworld

    Array
    (
        [a] => xishaonian
    [b] => helloworld )

    那么我如果那么写:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <?php
    $control = isset($_GET['m'])?$_GET['m']:'index';
    $action = isset($_GET['a'])?$_GET['a']:'index';
    $obj new $control();
    $obj->$action();
    class index
    {
        function index()
        {
            echo "this is index";
        }
        function handler()
        {
            echo "this is handler";
        }
    }
     
     
     ?>

      我如果要实例化index类然后访问hanler这个方法那么就是:http://127.0.0.1/2.php?m=index&a=handler

  • 相关阅读:
    redis学习
    Ubuntu命令大全
    关于jquery中attr和prop的用法
    Ubuntu下修改为永久DNS的方法
    Yii2 behaviors中verbs access的一些理解
    vue_ form表单 v-model
    vue-one_demo_music
    ES6
    VUE 入门 01
    Django model.py表单设置默认值允许为空
  • 原文地址:https://www.cnblogs.com/nul1/p/9427929.html
Copyright © 2011-2022 走看看