Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions language/oop5/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ Fatal error: Uncaught Error: Cannot access private const Foo::BAZ in …
As of PHP 7.1.0 visibility modifiers are allowed for class constants.
</para>
</note>
<example>
<title>Fetch class constant syntax, as of PHP 8.3.0</title>
<programlisting role="php">
<![CDATA[
<?php
class Foo {
public const BAR = 'bar';
private const BAZ = 'baz';
}

$name = 'BAR';
echo Foo::{$name}, PHP_EOL; // bar
?>
]]>
</programlisting>
</example>
<note>
<para>
As of PHP 8.3.0, class constants can be fetched dynamically using a
variable.
</para>
</note>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
Expand Down