ささやかな日々記

日々過ごす中で感じたことや培ったことが誰かの役に立てられたらと思うSEの雑記

PHP 7.2.x から PHP 7.3.x への移行の勝手な日本語訳 後方互換のない変更②

 PHP 7.2.x から PHP 7.3.x への移行の日本語訳がないので勝手に翻訳して備忘録にする。

https://www.php.net/manual/ja/migration73.incompatible.php 

 

「Heredoc/Nowdoc Ending Label Interpretation 」

Heredoc / Nowdocエンディングラベルの解釈

 Due to the introduction of flexible heredoc/nowdoc syntax, doc strings that contain the ending label inside their body may cause syntax errors or change in interpretation. For example in:

柔軟なheredoc / nowdoc構文が導入されたため、本体内に終了ラベルを含むdoc文字列は構文エラーの原因となったり、解釈が変更されたりする可能性があります。 例えば、

 

<?php
$str 
= <<<FOO
abcdefg
   FOO
FOO;
?>

the indented occurrence of FOO did not previously have any special meaning. Now it will be interpreted as the end of the heredoc string and the following FOO; will cause a syntax error. This issue can always be resolved by choosing an ending label that does not occur within the contents of the string.

 

インデントされたFOOの出現は、以前は特別な意味を持ちませんでした。 これは、heredoc文字列の末尾とそれに続くFOOとして解釈されます。 構文エラーが発生します。 この問題は、文字列の内容に含まれない終了ラベルを選択することで常に解決できます。

[商品価格に関しましては、リンクが作成された時点と現時点で情報が変更されている場合がございます。]

気づけばプロ並みPHP 改訂版ーーゼロから作れる人になる! [ 谷藤賢一 ]
価格:2916円(税込、送料無料) (2019/6/4時点)

楽天で購入