Revision #36 has been created by
rackycz on Oct 14, 2025, 8:50:24 AM with the memo:
edit
« previous (#35) next (#37) »
Changes
Title
unchanged
Yii3 - How to start
Category
unchanged
Tutorials
Yii version
unchanged
3.0
Tags
unchanged
Content
changed
[...]
## Construct vs Invoke
It may be confusing that some classes contain both methods. Note that "property promotion" should be only used in `__construct()`.
Magic method `__invoke()` is only used if you create an instance and then use it as a function. Example:
```php
$obj = new MyObj(); // Now the __construct() is executed
$obj(); // Now the __invoke() is executed
```
To be honest, I still do not fully understand the real purpose of this situation.[...]