标签:
场景:通过GoodsController下index/getInfo操作获取IndexContoller下的countx操作内容
GoodsController.class.php
<?php namespace Home\Controller; use Think\Controller; class GoodsController extends Controller { public function index(){ //实例化内容所在的控制器 $user = new IndexController(); echo $user -> countx(); } public function getinfo(){ //上面index()实例化的函数式写法 $user =A(‘Index‘); echo $user->countx(); } public function simpleget(){ //来个更加丧心病狂的方式 //R()函数实例化对象之后再调用其对应的方法 echo R("Index/countx"); } }
//内容所咋的IndexController.class.php
<?php namespace Home\Controller; use Think\Controller; class IndexController extends Controller { public function index(){ echo "<h1>hellomworld</h1>"; } public function countx(){ echo "<h1>1024</h1>"; } }
标签:
原文地址:http://my.oschina.net/dongdong11019/blog/486155