Answer the question
In order to leave comments, you need to log in
Closure vs call() vs construct() vs invoke() vs method?
What, when, why and why is it better to use?
Because I ran into a question, here it is necessary to use the invoke () method, is there any point in using the magic method of the constructor then? And why through magic?
It could be static, or something like that. So the question is how and when? Why?
I read the doc, and separately I roughly understand when to use each of the methods, the question arose when several magical ones are used. I also met init () on the open spaces of Google. I am sure that if you dig, you can still find a few hooks that help initialize the state of an object when it is created or called.
Answer the question
In order to leave comments, you need to log in
Everything is mixed horses - people ...
There is a set of magical functions. It's like hooks placed in important places. As the code is executed, php hooks on hooks and if something is hung on this hook, then it twitches.
php.net/manual/en/language.oop5.magic.php
has static methods, which are class methods and do not require the creation of a class object. They have their own characteristics, advantages and disadvantages. But you're talking about an object, so they don't fit
init() at all, off topic. This is just a function call (maybe a method) init
Specifically, you can answer 1 question.
Helps to initialize the state of an object when it is created - __construct
The rest of the questions are either fundamentally wrong or require clarification.
It should also be noted that php, like another language, provides many different tools for solving a problem. Which one to use is up to you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question