The followingthinkphp frameworkThe tutorial column will introduce to you how to solve the thinkphp new self() error problem. I hope it will be helpful to friends in need!
Specific problem description:
public function t2() { $receiver = new self(); }
Framework thinkphp6
Solution:
The error message is already obvious: __construct() is missing parameters. The code you posted does not pass in $app. I have not used TP6, but in a framework like this, the method of obtaining an object is When using a container, it will automatically inject dependencies (that is, automatically instantiate $app). If you use new, dependencies will not be injected.
So when using the container, you can do this: $receiver = invoke('xxx');
When using the new method, you can do this:
$app = new App(); $receiver = new Receiver($app);
For details, please refer to the documentation of TP6: https://www.kancloud.cn/manual/thinkphp6_0/1037489
Recommended: "The latest 10 thinkphp video tutorials"
The above is the detailed content of How to solve thinkphp new self() error problem. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
