diff --git a/components/yaml.rst b/components/yaml.rst index a04ad7afe35..b7ceec4e25a 100644 --- a/components/yaml.rst +++ b/components/yaml.rst @@ -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 ~~~~~~~~~~~~~~~~~