当前位置:网站首页>如何在业务代码中使用 ThinkPHP5.1 封装的容器内反射方法
如何在业务代码中使用 ThinkPHP5.1 封装的容器内反射方法
2022-07-06 05:47:00 【北桥苏】

invokeClass
用法:可以不传命名空间实例化 (通过反射实例化)
$obj = Container::getInstance()->invokeClass(InvokerTest::class);
var_dump($obj->invokerNews());die;
-----------------------------------------------------------------------
invokeMethod
用法:传入带命名空间的类和对应方法,实例化后调用该方法
$methods = Container::getInstance()->invokeMethod(["app\common\service\InvokerTest", "invokerNews"]);
var_dump($methods);die;

-----------------------------------------------------------------------
invokeFunction
用法:可以执行自定义的函数和闭包,参数以数组形式传递
$functions = Container::getInstance()->invokeFunction(function ($name) {
return "hello {$name}";
}, ["beiqiaosu"]);
var_dump($functions);die;
$functions = Container::getInstance()->invokeFunction("procmsg", ["12312", "heillo"]);
var_dump($functions);die;
-----------------------------------------------------------------------
invoke
用法:invokeFunction 和 invokeMethod 结合体
$invoke = Container::getInstance()->invoke(["app\common\service\InvokerTest", "invokerNews"]);
var_dump($invoke);die;
边栏推荐
- Go language -- language constants
- 01. Project introduction of blog development project
- 关于 PHP 启动 MongoDb 找不到指定模块问题
- Migrate Infones to stm32
- Auto.js学习笔记17:基础监听事件和UI简单的点击事件操作
- YYGH-11-定时统计
- Text classification still stays at Bert? The dual contrast learning framework is too strong
- [machine learning notes] univariate linear regression principle, formula and code implementation
- Improve jpopup to realize dynamic control disable
- Market development prospect and investment risk assessment report of China's humidity sensor industry from 2022 to 2028
猜你喜欢

Baidu online AI competition - image processing challenge: the 8th program of handwriting erasure

B站刘二大人-线性回归及梯度下降

Hongliao Technology: how to quickly improve Tiktok store

How to download GB files from Google cloud hard disk

YYGH-11-定时统计
![[experience] install Visio on win11](/img/f5/42bd597340d0aed9bfd13620bb0885.png)
[experience] install Visio on win11

网络协议模型

Station B Liu Erden - linear regression and gradient descent

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Analysis of grammar elements in turtle Library
随机推荐
Station B Liu Erden softmx classifier and MNIST implementation -structure 9
数字经济破浪而来 ,LTD是权益独立的Web3.0网站?
Station B Liu Erden linear regression pytoch
Promise summary
Query the standard text code corresponding to a work center (s) in the production order
清除浮动的方式
B站刘二大人-多元逻辑回归 Lecture 7
Report on market depth analysis and future trend prediction of China's arsenic trioxide industry from 2022 to 2028
华为路由器如何配置静态路由
Practice sharing: how to safely and quickly migrate from CentOS to openeuler
[cloud native] 3.1 kubernetes platform installation kubespher
进程和线程
wib3.0 跨越,在跨越(ง •̀_•́)ง
High quality coding tool clion
A master in the field of software architecture -- Reading Notes of the beauty of Architecture
Redis消息队列
Self built DNS server, the client opens the web page slowly, the solution
Web服务连接器:Servlet
Anti shake and throttling are easy to understand
Auto.js学习笔记17:基础监听事件和UI简单的点击事件操作