调用控制器


调用其他控制器

在控制器内直接使用 new 关键字实例化其他控制器类即可完成对其他控制器的调用


演示代码

在 index 控制器内调用 test 控制器并执行其 runme 方法


test.php 源码

				
<?php

class testController extends Mb{
	public function runme(){
		print_r($this->gets);//输出
	}	
}
				
			

index.php 源码

				
<?php 
class indexController extends Mb{
	public function index(){
		
		$testController = new testController();
		// 设置 gets 数据
		$testController->gets = ['query','202212191549021','1671436223'];
		$testController->runme();
	}
	
}