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

Added docs for Yaml::PARSE_CONSTANT #7194

New issue 8000

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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