I'm trying to learn how attributes in PHP work. But when I wrote some code (I have XAMPP with PHP 8 support installed), it doesn't seem to work (no message on the screen). Does it need additonal configuration to work?
use Attribute;
class MyAttribute {
public function __construct($message) {
// I want to show this message when using MyAttribute
echo $message;
}
}
#[MyAttribute('hello')]
class SomeClass {
// ...
}
Shouldn't this code show me "hello" message? Or I don't understand something? It doesn't show anything.