当前位置:网站首页>如何在业务代码中使用 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;
边栏推荐
- 26file filter anonymous inner class and lambda optimization
- PDK process library installation -csmc
- 授予渔,从0开始搭建一个自己想要的网页
- Clear floating mode
- B站刘二大人-数据集及数据加载 Lecture 8
- Database: ODBC remote access SQL Server2008 in oracel
- Pytorch代码注意的细节,容易敲错的地方
- Station B, Mr. Liu Er - multiple logistic regression, structure 7
- Embedded interview questions (I: process and thread)
- 华为路由器忘记密码怎么恢复
猜你喜欢

Text classification still stays at Bert? The dual contrast learning framework is too strong

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

01. Project introduction of blog development project

How to use PHP string query function
[email protected]树莓派"/>[email protected]树莓派

MIT6.s081-2020 Lab2 System Calls

Deep learning -yolov5 introduction to actual combat click data set training

Station B Liu Erden - linear regression and gradient descent

Processes and threads

Redis消息队列
随机推荐
[Jiudu OJ 07] folding basket
[force buckle]43 String multiplication
Codeless June event 2022 codeless Explorer conference will be held soon; AI enhanced codeless tool launched
A master in the field of software architecture -- Reading Notes of the beauty of Architecture
Demander le Code de texte standard correspondant à un centre de travail dans l'ordre de production
Anti shake and throttling are easy to understand
[QNX hypervisor 2.2 user manual]6.3.3 using shared memory (shmem) virtual devices
Station B Liu Erden softmx classifier and MNIST implementation -structure 9
Sequoiadb Lake warehouse integrated distributed database, June 2022 issue
【论文代码】SML部分代码阅读
移植InfoNES到STM32
Self built DNS server, the client opens the web page slowly, the solution
H3C防火墙RBM+VRRP 组网配置
Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
What is independent IP and how about independent IP host?
LeetCode_字符串反转_简单_557. 反转字符串中的单词 III
Report on market depth analysis and future trend prediction of China's arsenic trioxide industry from 2022 to 2028
Station B Liu Erden linear regression pytoch
Web Security (VI) the use of session and the difference between session and cookie
Embedded interview questions (IV. common algorithms)