当前位置:网站首页>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;
边栏推荐
- First knowledge database
- P2802 go home
- As3013 fire endurance test of cable distribution system
- Station B Liu Erden linear regression pytoch
- Implementation of linked list in address book management system
- Redis6 cluster setup
- [imgui] unity MenuItem shortcut key
- 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
- [Jiudu OJ 08] simple search x
- [string] palindrome string of codeup
猜你喜欢
SequoiaDB湖仓一体分布式数据库2022.6月刊
[Baiwen smart home] first day of the course_ Learn Embedded and understand the development mode of bare metal and RTOS
- [email protected]树莓派"/>
[email protected]树莓派
Mysql database master-slave cluster construction
Redis消息队列
数字经济破浪而来 ,LTD是权益独立的Web3.0网站?
Rustdesk builds its own remote desktop relay server
H3C firewall rbm+vrrp networking configuration
Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
Li Chuang EDA learning notes 12: common PCB board layout constraint principles
随机推荐
ArcGIS application foundation 4 thematic map making
实践分享:如何安全快速地从 Centos迁移到openEuler
Title 1093: character reverse order
Auto.js学习笔记17:基础监听事件和UI简单的点击事件操作
[happy Spring Festival] if you feel happy, dance
Is it difficult for an information system project manager?
Selective parameters in MATLAB functions
Auto. JS learning notes 17: basic listening events and UI simple click event operations
My 2021
大型网站如何选择比较好的云主机服务商?
RustDesk 搭建一个自己的远程桌面中继服务器
Download, install and use NVM of node, and related use of node and NRM
LTE CSFB process
How to use PHP string query function
J'ai un chaton.
How can large websites choose better virtual machine service providers?
Luogu [Beginner Level 4] array p1427 number game of small fish
Web Security (V) what is a session? Why do I need a session?
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
[string] palindrome string of codeup