当前位置:网站首页>How to use the container reflection method encapsulated by thinkphp5.1 in business code
How to use the container reflection method encapsulated by thinkphp5.1 in business code
2022-07-06 05:54:00 【Beiqiaosu】
invokeClass
usage : Namespace instantiation is not required ( Instantiated by reflection )
$obj = Container::getInstance()->invokeClass(InvokerTest::class);
var_dump($obj->invokerNews());die;
-----------------------------------------------------------------------
invokeMethod
usage : Pass in the class with namespace and the corresponding method , Call this method after instantiation
$methods = Container::getInstance()->invokeMethod(["app\common\service\InvokerTest", "invokerNews"]);
var_dump($methods);die;
-----------------------------------------------------------------------
invokeFunction
usage : You can execute custom functions and closures , Parameters are passed as an array
$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
usage :invokeFunction and invokeMethod A combination
$invoke = Container::getInstance()->invoke(["app\common\service\InvokerTest", "invokerNews"]);
var_dump($invoke);die;
边栏推荐
- 养了只小猫咪
- Station B, Master Liu Er - back propagation
- Download, install and use NVM of node, and related use of node and NRM
- YYGH-11-定时统计
- Some easy-to-use tools make your essay style more elegant
- 【论文代码】SML部分代码阅读
- 如何在业务代码中使用 ThinkPHP5.1 封装的容器内反射方法
- How Huawei routers configure static routes
- Leetcode 701 insertion operation in binary search tree -- recursive method and iterative method
- 数字经济破浪而来 ,LTD是权益独立的Web3.0网站?
猜你喜欢
[email protected] raspberry pie"/>
[email protected] raspberry pie
数字经济破浪而来 ,LTD是权益独立的Web3.0网站?
PDK process library installation -csmc
[SQL Server fast track] - authentication and establishment and management of user accounts
P2802 go home
局域网同一个网段通信过程
What preparations should be made for website server migration?
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
J'ai un chaton.
Station B, Master Liu Er - dataset and data loading
随机推荐
Raised a kitten
As3013 fire endurance test of cable distribution system
27io stream, byte output stream, OutputStream writes data to file
[imgui] unity MenuItem shortcut key
实践分享:如何安全快速地从 Centos迁移到openEuler
【SQL server速成之路】——身份驗證及建立和管理用戶賬戶
Installation de la Bibliothèque de processus PDK - csmc
[force buckle]43 String multiplication
CoDeSys note 2: set coil and reset coil
Yygh-11-timing statistics
Station B, Master Liu Er - back propagation
(column 22) typical column questions of C language: delete the specified letters in the string.
Station B Liu Erden softmx classifier and MNIST implementation -structure 9
Auto.js学习笔记17:基础监听事件和UI简单的点击事件操作
The usage and difference between strlen and sizeof
Report on market depth analysis and future trend prediction of China's arsenic trioxide industry from 2022 to 2028
[Baiwen smart home] first day of the course_ Learn Embedded and understand the development mode of bare metal and RTOS
Huawei BFD configuration specification
c语言——冒泡排序
Quantitative description of ANC noise reduction