rfc:heredoc-with-double-quotes

This is an old revision of the document!


Request for Comments: Allow HEREDOC syntax with double quotes

  • Version: 0.1.1
  • Date: 2008-03-22
  • Author: Lars Strojny
  • Votes: (+4/-4)
    • Pro: Pierre A. Joye, Christopher Jones, Marcus Boerger, Gwynne Raskind, Lars Strojny
    • Contra: Steph Fox, Edward Z. Yang, Hannes Magnusson, Stanislav Malyshev

Purpose

In 5_3 we introduced NOWDOC in and it would be logical to allow a double quoted syntax sister of NOWDOC which acts as HEREDOC. The reason to do this is mainly consistency with with variable declarations:

$var = '$var'; // Literally
$var = "$var"; // Intepreted

Code examples

Classic HEREDOC

$var = 'Hello world';
 
$str = <<<LABEL
$var
LABEL;
 
echo $str; // gives: Hello world

“$var” is interpreted.

NOWDOC

$var = 'Hello world';
 
$str = <<<'LABEL'
$var
LABEL;
 
echo $str; // gives: $var

“$var” is taken literally.

Proposed HEREDOC

$var = 'Hello world';
 
$str = <<<"LABEL"
$var
LABEL;
 
echo $str; // gives: Hello world

“$var” would be interpreted.

rfc/heredoc-with-double-quotes.1206727658.txt.gz · Last modified: 2017/09/22 13:28 (external edit)