A函数跨区域

ODerController.class.php内容如下 

1
<?php 2 3 /* 4 * To change this license header, choose License Headers in Project Properties. 5 * To change this template file, choose Tools | Templates 6 * and open the template in the editor. 7 */ 8 9 namespace HomeController; 10 use ThinkController; 11 class ODerController extends Controller{ 12 //未付款的信息 13 public function gwc(){ 14 echo dddd; 15 } 16 }
 UserController.class.php内容如下:
1
<?php 2 3 /* 4 * To change this license header, choose License Headers in Project Properties. 5 * To change this template file, choose Tools | Templates 6 * and open the template in the editor. 7 */ 8 9 10 11 namespace HomeController; 12 use ThinkController; 13 class UserController extends Controller{ 14 15 public function info(){ 16 // echo '5555'; 17 /* 18 * 跨控制器调用,现在是自己在调用 19 20 $order = new HomeControllerODerController(); 21 $order->gwc(); 22 */ 23 24 /*跨控制器调用,使用A()函数 25 $order=A('Home/ODer'); 26 *dump();tp系统函数,开发小组自己用的,带有格式的输出 27 *dump($order); 28 * $order->gwc(); 29 */ 30 } 31 }

备注:

A函数
    作用:实例化控制器的一个快捷函数

    格式:A(模板/控制器,[控制器层名称]);

  跨控制器调用

    本次练习是在ThinkPHP_3.2_140202下操作的

原文地址:https://www.cnblogs.com/StinkyKids/p/6439793.html