Skip to content

Commit c56f7ee

Browse files
committed
Added docs for Yaml::PARSE_CONSTANT
1 parent f0db5af commit c56f7ee

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

components/yaml.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ flag::
293293
// Line
294294
// String
295295

296+
Parsing PHP Constants
297+
~~~~~~~~~~~~~~~~~~~~~
298+
299+
By default the YAML parser treats the PHP constants included in the contents as
300+
regular strings. Use the ``PARSE_CONSTANT`` flag and the special ``!php/const:``
301+
syntax to parse them as proper PHP constants::
302+
303+
$yaml = '{ foo: PHP_INT_SIZE, bar: !php/const:PHP_INT_SIZE }';
304+
$parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT);
305+
// $parameters = array('foo' => 'PHP_INT_SIZE', 'bar' => 8);
306+
296307
Learn More
297308
----------
298309

0 commit comments

Comments
 (0)