2
2
zend_constant
3
3
###############
4
4
5
- PHP constants (referring to non-class constants) are stored in a dedicated
6
- structure ``zend_constant ``, which holds both the value of the constant and
7
- details for using it.
5
+ PHP constants (referring to non-class constants) are stored in a dedicated structure
6
+ ``zend_constant ``, which holds both the value of the constant and details for using it.
8
7
9
8
************
10
9
definition
@@ -18,21 +17,18 @@ details for using it.
18
17
zend_string *filename;
19
18
} zend_constant;
20
19
21
- The ``value `` field stores both the value itself and some metadata. The ``name ``
22
- and ``filename `` store the name of the constant and the name of the file in
23
- which it was defined.
20
+ The ``value `` field stores both the value itself and some metadata. The ``name `` and ``filename ``
21
+ store the name of the constant and the name of the file in which it was defined.
24
22
25
- ******
23
+ *******
26
24
value
27
- ******
25
+ *******
28
26
29
- The value of the constant is stored in the :doc: `./zval ` ``value ``. However,
30
- since the ``zval `` structure has extra space, for constants this is used to
31
- store both the number of the module that the constant was defined in, and a
32
- combination of the flags that affect the usage of the constant.
27
+ The value of the constant is stored in the :doc: `./zval ` ``value ``. However, since the ``zval ``
28
+ structure has extra space, for constants this is used to store both the number of the module that
29
+ the constant was defined in, and a combination of the flags that affect the usage of the constant.
33
30
34
- This extra information is placed in the ``uint32_t `` field
35
- ``value.u2.constant_flags ``.
31
+ This extra information is placed in the ``uint32_t `` field ``value.u2.constant_flags ``.
36
32
37
33
The bottom 16 bits are used to hold flags about the constant
38
34
@@ -44,28 +40,25 @@ The bottom 16 bits are used to hold flags about the constant
44
40
#define CONST_OWNED (1<<3) /* constant should be destroyed together
45
41
with class */
46
42
47
- These bottom 16 bits can be accessed with the ``ZEND_CONSTANT_FLAGS() `` macro,
48
- which is given a ``zend_constant `` pointer as a parameter.
43
+ These bottom 16 bits can be accessed with the ``ZEND_CONSTANT_FLAGS() `` macro, which is given a
44
+ ``zend_constant `` pointer as a parameter.
49
45
50
- On the other hand, the top 16 bits are used to store the number of the PHP
51
- module that registered the constant. For constants defined by the user, the
52
- module number stored will be ``PHP_USER_CONSTANT ``. This module number can be
53
- accessed with the ``ZEND_CONSTANT_MODULE_NUMBER() `` macro, which is likewise
54
- given a ``zend_constant `` pointer as a parameter.
46
+ On the other hand, the top 16 bits are used to store the number of the PHP module that registered
47
+ the constant. For constants defined by the user, the module number stored will be
48
+ ``PHP_USER_CONSTANT ``. This module number can be accessed with the ``ZEND_CONSTANT_MODULE_NUMBER() ``
49
+ macro, which is likewise given a ``zend_constant `` pointer as a parameter.
55
50
56
51
******
57
52
name
58
53
******
59
54
60
- The ``name `` holds a :doc: `zend_string ` with the name of the constant, to allow
61
- searching for constants that have already been defined. This string is released
62
- when the constant itself is freed.
55
+ The ``name `` holds a :doc: `zend_string ` with the name of the constant, to allow searching for
56
+ constants that have already been defined. This string is released when the constant itself is freed.
63
57
64
- ******
58
+ **********
65
59
filename
66
- ******
60
+ **********
67
61
68
- Finally, the ``filename `` holds another ``zend_string `` with the name of the
69
- file in which the constant was defined, or ``NULL `` if not defined userland
70
- code. This field provides the foundation for the PHP method
71
- ``ReflectionConstant::getFileName() ``.
62
+ Finally, the ``filename `` holds another ``zend_string `` with the name of the file in which the
63
+ constant was defined, or ``NULL `` if not defined userland code. This field provides the foundation
64
+ for the PHP method ``ReflectionConstant::getFileName() ``.
0 commit comments