DTapi教程:19.怎样使用扩展
发表:DESTOON模板堂(dtmoban.com)
发表时间:2019-10-11
说明
使用扩展和使用模型是一样的,use 扩展命名空间,然后注入方法用使用即可。
例:有扩展 test.php ,在index.php控制器需要使用其中的方法 excel();
index.php
<?php namespace dtapp\demo; use dtapp\demo\ext\test; class index { public function index(test $test){ $test->excel(); } } ?>
提示
如果您不了解命名空间,也不了解use 更不了解依赖注入,都没关系。
直接把上面的 use dtapp\demo\ext\test; 改成 use dtapp\你的应用名\ext\扩展名;
把index()参数中的 test $test 改成你对应的扩展即可。
还是不会,那就先好好学学php了。