8000 Added docs for Yaml::PARSE_CONSTANT · symfony/symfony-docs@fe7f5c5 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe7f5c5

Browse files
javiereguiluzxabbuh
authored andcommitted
Added docs for Yaml::PARSE_CONSTANT
1 parent 7a8e74a commit fe7f5c5

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
Syntax Validation
297308
~~~~~~~~~~~~~~~~~
298309

0 commit comments

Comments
 (0)
0