|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-02-18 16:58 UTC] edg at greenberg dot org
Description: ------------ --- From manual page: https://php.net/tokenizer.examples --- The example code conflicts (does exactly the wrong thing) with the warning on documentation page: https://www.php.net/manual/en/tokens.php wherein it is written: Note: Usage of T_* constants All tokens listed below are also defined as PHP constants. Their value is automatically generated based on PHP's underlying parser infrastructure. This means that the concrete value of a token may change between two PHP versions. For example the T_FILE constant is 365 in PHP 5.3, while the same value refers now to T_TRAIT in PHP 5.4 and the value of T_FILE is 369. This means that your code should never rely directly on the original T_* values taken from PHP version X.Y.Z, to provide some compatibility across multiple PHP versions. Instead your code should utilize custom values (using big numbers like 10000) and an appropriate strategy that will work with both PHP versions and T_* values. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 05:00:02 2025 UTC |
> I'm not even sure what that's talking about. I was very confused about that as well, but Nikita clarified: > The point is that you shouldn't do something like > if (!defined('T_ENUM')) define('T_ENUM', VALUE_OF_T_ENUM_IN_PHP_8_1);