Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.php > #4760
| From | k@rl.pflaesterer.de (Karl Pflästerer) |
|---|---|
| Newsgroups | de.comp.lang.php |
| Subject | Re: ::class und constant() |
| Date | 2022-01-10 22:29 +0100 |
| Message-ID | <m1v8yri8ki.fsf@mbp.pflaesterer.de> (permalink) |
| References | <1t61dbfeaei1306d1n3e8%sfroehli@Froehlich.Priv.at> |
Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) writes:
> Das folgende Codefragment:
>
> #v+
> <?php
>
> class C {
> const c = 'c';
> }
>
> var_dump(constant('C::class'));
>
> ?>
> #v-
>
> ergibt bis einschließlich PHP 7.4 "NULL", ab PHP 8.0 offenbar (das
> habe ich nur mit 3v4l.org getestet) einen fatal error.
>
> Ist das ein Bug, ein Feature, oder halt einfach so passiert? Wieso
> darf ::class, das im Manual als "special constant" bezeichnet wird,
> nicht wie eine Konstante verwendet werden?
Was hättest du denn erwartet?
,----[ https://www.php.net/constant: ]
| 8.0.0 If the constant is not defined, constant() now throws an Error
| exception; previously an E_WARNING was generated, and null was returned.
`----
Vorher ging es nicht und lieferte NULL, nun mit PHP 8 geht es nicht und
gibt eine Exception
Back to de.comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar
::class und constant() Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2022-01-10 09:46 +0000
Re: ::class und constant() k@rl.pflaesterer.de (Karl Pflästerer) - 2022-01-10 22:29 +0100
Re: ::class und constant() Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2022-01-10 23:12 +0000
Re: ::class und constant() Arno Welzel <usenet@arnowelzel.de> - 2022-01-11 11:50 +0100
Re: ::class und constant() Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2022-01-11 13:41 +0000
Re: ::class und constant() k@rl.pflaesterer.de (Karl Pflästerer) - 2022-01-11 16:40 +0100
Re: ::class und constant() Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2022-01-11 17:36 +0000
csiph-web