note 128452 added to language.oop5.constants
| From: | powtac at gmx dot de | Date: | Fri, 05 May 2023 14:02:08 +0000 |
| Subject: | note 128452 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220408@lists.php.net to get a copy of this message | ||
Since it it is not mentioned in the description the following types can be set as a class constant:
string, array, int, bool and probably float. But not objects.
<?php
class Test {
const arr = array();
const string = 'string';
const int = 99;
const bool = true;
}
var_dump(
(new Test())::arr,
(new Test())::string,
(new Test())::int,
(new Test())::bool
);
/* ouput for PHP 7.0.0+:
array(0) {
}
string(6) "string"
int(99)
bool(true)
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 2a02:8071:a86:78c0:11d5:7d8d:1cd8:33c1)
----
Manual Page -- https://php.net/manual/en/language.oop5.constants.php
Edit -- https://main.php.net/note/edit/128452
Del: integrated -- https://main.php.net/note/delete/128452/integrated
Del: useless -- https://main.php.net/note/delete/128452/useless
Del: bad code -- https://main.php.net/note/delete/128452/bad+code
Del: spam -- https://main.php.net/note/delete/128452/spam
Del: non-english -- https://main.php.net/note/delete/128452/non-english
Del: in docs -- https://main.php.net/note/delete/128452/in+docs
Del: other reasons-- https://main.php.net/note/delete/128452
Reject -- https://main.php.net/note/reject/128452
Search -- https://main.php.net/manage/user-notes.php