8000 Added docs for Yaml::PARSE_CONSTANT by javiereguiluz · Pull Request #7194 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions components/yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ flag::
// Line
// String

Parsing PHP Constants
~~~~~~~~~~~~~~~~~~~~~

By default, the YAML parser treats the PHP constants included in the contents as
regular strings. Use the ``PARSE_CONSTANT`` flag and the special ``!php/const:``
syntax to parse them as proper PHP constants::

$yaml = '{ foo: PHP_INT_SIZE, bar: !php/const:PHP_INT_SIZE }';
$parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT);
// $parameters = array('foo' => 'PHP_INT_SIZE', 'bar' => 8);

Syntax Validation
~~~~~~~~~~~~~~~~~

Expand Down
0