Attribute Class

This is a native PHP attribute, which tells the engine that a class is a PHP attribute.

This attribute is not necessary to make a class a valid attribute. Yet, it is recommended to use it and make the classes explicitly attributes.

<?php

    #[Attribute]
    class MyAttribute { }

    #[MyAttribute]
    class MyClass { }

?>

Documentation

See also Attributes in PHP 8 and A guide to PHP attributes.

Related : Override Attribute, NoDiscard, Attribute, PHP Native Attributes

Added in PHP 8.1+