From 2ae783e6b55dcd5672c290fe13878c03a1edeb37 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 7 Nov 2011 16:12:16 +0000 Subject: [PATCH] Add note about inconsistent T_* constant values across PHP versions (thanks anonymous 11741) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@318883 c90b9560-bf6c-de11-be94-00142212c4b1 --- appendices/tokens.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/appendices/tokens.xml b/appendices/tokens.xml index f2a7792406..8b50b9577b 100644 --- a/appendices/tokens.xml +++ b/appendices/tokens.xml @@ -13,6 +13,24 @@ know that, here is a table with those identifiers, PHP-syntax and references to the appropriate places in the manual. + + + 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. + + + Tokens