zoukankan      html  css  js  c++  java
  • tp5 方法控制器的调用

    1、命名空间
    2、use方法
    3、使用系统方法
    <?php namespace appindexcontroller; useappindexcontrollerIndex as adminIndex; class test1{ public function test1(){ echo "我是index模块下的test1控制器中的test1方法"; } public function test(){ //相同模块下 $u = new User(); $u->index(); echo "<hr>"; $u = controller('User'); $u->index(); echo "<hr>"; //不同模块下 $u = controller('admin/Index'); $u->index(); echo "<hr>"; //使用命名空间调用相同模块下的控制器 $u = new appadmincontrollerindex; $u-> test1(); echo "<hr>"; //使用面向对象 $u = new adminIndex; $u->test1(); } public function getFunc(){ //使用相同控制器下的方法 $this->test1(); echo "<hr>"; self::test1(); echo "<hr>"; test1::test1(); echo "<hr>"; action('test1'); echo "<hr>"; //调用相同模块下不同控制器的方法 action('User/test'); echo "<hr>"; $u = new User; $u->test(); echo "<hr>"; //调用不同模块下不同控制器下的方法 action('admin/Index/index'); echo "<hr>"; $u = new appadmincontrollerIndex; $u->index(); } public function test1(){ echo "我是测试方法的方法"; } } ?>
  • 相关阅读:
    luogu_1009 阶乘之和
    codevs_3117 高精度练习之乘法(my struct)
    luogu_2142 高精度减法
    luogu_1601 A+B Problem(高精)
    luogu_1007 独木桥
    luogu_1006 传纸条
    luogu_1004 方格取数
    luogu_1003 铺地毯
    luogu_1002 过河卒
    BZOJ 2560: 串珠子 (状压DP+枚举子集补集+容斥)
  • 原文地址:https://www.cnblogs.com/zhengleilei/p/9410980.html
Copyright © 2011-2022 走看看