当前位置:网站首页>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;
边栏推荐
- B站刘二大人-反向传播
- Game push image / table /cv/nlp, multi-threaded start
- Network protocol model
- LTE CSFB process
- Web Security (VI) the use of session and the difference between session and cookie
- Redis6 cluster setup
- AUTOSAR从入门到精通番外篇(十)-嵌入式S19文件解析
- [Tang Laoshi] C -- encapsulation: classes and objects
- Migrate Infones to stm32
- (column 22) typical column questions of C language: delete the specified letters in the string.
猜你喜欢

ArcGIS application foundation 4 thematic map making

Garbage collector with serial, throughput priority and response time priority

Processes and threads

Installation de la Bibliothèque de processus PDK - csmc

Leetcode 701 insertion operation in binary search tree -- recursive method and iterative method

H3C V7版本交换机配置IRF

Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution

High quality coding tool clion

Construction of yolox based on paste framework

59. Spiral matrix
随机推荐
Migrate Infones to stm32
Analysis of grammar elements in turtle Library
Closure, decorator
Mysql database master-slave cluster construction
Game push image / table /cv/nlp, multi-threaded start
Node 之 nvm 下载、安装、使用,以及node 、nrm 的相关使用
The usage and difference between strlen and sizeof
关于 PHP 启动 MongoDb 找不到指定模块问题
What impact will frequent job hopping have on your career?
Web Security (VI) the use of session and the difference between session and cookie
ArcGIS application foundation 4 thematic map making
Summary of data sets in intrusion detection field
Memory and stack related concepts
数字经济破浪而来 ,LTD是权益独立的Web3.0网站?
【无标题】
Quantitative description of ANC noise reduction
Auto.js学习笔记17:基础监听事件和UI简单的点击事件操作
进程和线程
[SQL Server fast track] - authentication and establishment and management of user accounts
[JVM] [Chapter 17] [garbage collector]