# [RFC] Double quoted NOWDOC is HEREDOC

- Thread: https://externals.io/message/36335
- Original archive: https://news-web.php.net/php.internals/36335
- Started by Lars Strojny on 2008-03-22T20:17:27+00:00
- Messages: 18
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #36335 — Lars Strojny — 2008-03-22T20:17:27+00:00

URL: https://externals.io/message/36335#36335

Hi,

as we introduce NOWDOC in 5.3 it would be logical to allow a double
quoted syntax sister of NOWDOC which acts as HEREDOC (same as for $var =
"$var" vs $var = '$var'). Currently we have the following options:

$var = "Hello world";

$str = <<<LABEL
$var
LABEL;

$str = <<<'LABEL'
$var
LABEL;

The first one is HEREDOC and $var would be evaluated. The second one is
NOWDOC and $var would be used literally. The following patch adds a
third version:

$str = <<<"LABEL"
$var
LABEL;

This acts as HEREDOC, therefore $var would be interpreted.

Comments?

cu, Lars

---

## #36348 — Stanislav Malyshev — 2008-03-23T01:43:18+00:00

URL: https://externals.io/message/36335#36348 · In reply to: #36335

> NOWDOC and $var would be used literally. The following patch adds a
> third version:
> 
> $str = <<<"LABEL"
> $var
> LABEL;

-1, we already have syntax for that.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36353 — Steph Fox — 2008-03-23T01:58:03+00:00

URL: https://externals.io/message/36335#36353 · In reply to: #36335

Hi Lars, oh wow no <<< again...

==================
as we introduce NOWDOC in 5.3 it would be logical to allow a double
quoted syntax sister of NOWDOC which acts as HEREDOC (same as for $var =
"$var" vs $var = '$var'). Currently we have the following options:

$var = "Hello world";

$str = <<<LABEL
$var
LABEL;

$str = <<<'LABEL'
$var
LABEL;

The first one is HEREDOC and $var would be evaluated. The second one is
NOWDOC and $var would be used literally. The following patch adds a
third version:

$str = <<<"LABEL"
$var
LABEL;

This acts as HEREDOC, therefore $var would be interpreted.

Comments?
=================

Just one. Why?

(-1, in case that wasn't clear)

- Steph

---

## #36357 — Edward Z. Yang — 2008-03-23T02:39:11+00:00

URL: https://externals.io/message/36335#36357 · In reply to: #36353

Steph Fox wrote:
> Just one. Why?

Probably to be consistent. Let's say a hypothetical user learns to use
NOWDOC before HEREDOC: which syntax are they more likely to use;
'NOWDOC' or "HEREDOC".

However, I too am -1 because this smacks of the Perl philosophy of "more
than one to do things", which, in terms of syntax, is completely
unnecessary.

-- 
 Edward Z. Yang                        GnuPG: 0x869C48DA
 HTML Purifier <http://htmlpurifier.org> Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]

---

## #36367 — Hannes Magnusson — 2008-03-23T11:51:10+00:00

URL: https://externals.io/message/36335#36367 · In reply to: #36335

>
>  $str = <<<"LABEL"
>  $var
>  LABEL;


-1 no please

-Hannes

---

## #36418 — Lars Strojny — 2008-03-24T10:55:01+00:00

URL: https://externals.io/message/36335#36418 · In reply to: #36353

Hi Steph,

Am Sonntag, den 23.03.2008, 01:58 +0000 schrieb Steph Fox:
> 
> Just one. Why?

We have double and single quotes for variable assignments. On of the
reasons we use single quotes for NOWDOC was because it is as in variable
assignments. If we follow that argument, there is no reason why 
$var = <<<"LABEL"
foo
LABEL;
should no work. That's why :-)

cu, Lars

---

## #36421 — Marcus Boerger — 2008-03-24T12:59:43+00:00

URL: https://externals.io/message/36335#36421 · In reply to: #36335

Hello Lars,

  to me this makes pretty much sense on a second glance as it perfectly
reflects what our string would do. And for someone learning 'NOWDOC',
using "HEREDOC" seems just natural.
So I am all +1
Consistency and satisfying expectations rocks!

marcus

Saturday, March 22, 2008, 9:17:27 PM, you wrote:

> Hi,

> as we introduce NOWDOC in 5.3 it would be logical to allow a double
> quoted syntax sister of NOWDOC which acts as HEREDOC (same as for $var =
> "$var" vs $var = '$var'). Currently we have the following options:

> $var = "Hello world";

> $str = <<<LABEL
> $var
> LABEL;

> $str = <<<'LABEL'
> $var
> LABEL;

> The first one is HEREDOC and $var would be evaluated. The second one is
> NOWDOC and $var would be used literally. The following patch adds a
> third version:

> $str = <<<"LABEL"
> $var
> LABEL;

> This acts as HEREDOC, therefore $var would be interpreted.

> Comments?

> cu, Lars



Best regards,
 Marcus

---

## #36647 — Lars Strojny — 2008-03-28T13:23:21+00:00

URL: https://externals.io/message/36335#36647 · In reply to: #36335

Hi,

Am Samstag, den 22.03.2008, 21:17 +0100 schrieb Lars Strojny:
> [RFC] Double quoted NOWDOC is HEREDOC

I've added this RFC to the Wiki too:
http://wiki.php.net/rfc/heredoc-with-double-quotes

cu, Lars

---

## #36652 — Gwynne Raskind — 2008-03-28T14:14:48+00:00

URL: https://externals.io/message/36335#36652 · In reply to: #36421

> Hello Lars,
>
>  to me this makes pretty much sense on a second glance as it perfectly
> reflects what our string would do. And for someone learning 'NOWDOC',
> using "HEREDOC" seems just natural.
> So I am all +1
> Consistency and satisfying expectations rocks!
>
> marcus

As the original proposer of nowdocs, I also give it a +1 for  
consistency!

-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."

> Saturday, March 22, 2008, 9:17:27 PM, you wrote:
> > […]
>
> Best regards,
> Marcus

---

## #36657 — Richard Quadling — 2008-03-28T17:16:53+00:00

URL: https://externals.io/message/36335#36657 · In reply to: #36652

> 
> > […]
>
>
> As the original proposer of nowdocs, I also give it a +1 for
>  consistency!

Would the closing tag also require the quotes (none/single/double)
depending upon how the opening tag was quoted (or not)?

And is "double-quoting" going to be in addition to no quoting?

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

---

## #36666 — Felipe Pena — 2008-03-28T23:28:25+00:00

URL: https://externals.io/message/36335#36666 · In reply to: #36421

2008/3/24, Marcus Boerger <helly@php.net>:
> Hello Lars,
>
>   to me this makes pretty much sense on a second glance as it perfectly
>  reflects what our string would do. And for someone learning 'NOWDOC',
>  using "HEREDOC" seems just natural.
>  So I am all +1
>  Consistency and satisfying expectations rocks!
>
>  marcus

+1 for same reason.

However, the patch is wrong, see below:

$foo = 'foobar';

$test = <<<"a
$foo
a;

var_dump($test);
/*
string(7) "foobar
"
*/

$test = b<<<"a"
$foo
a;

/*
Parse error: syntax error, unexpected $end
*/

Here's a possible fix:
- http://felipe.ath.cx/diff/double-quote-heredoc.diff


Regards,
Felipe Pena.

---

## #36672 — Lars Strojny — 2008-03-29T11:36:25+00:00

URL: https://externals.io/message/36335#36672 · In reply to: #36666

Hi Felipe,

Am Freitag, den 28.03.2008, 20:28 -0300 schrieb Felipe Pena:
> 2008/3/24, Marcus Boerger <helly@php.net>:
[...]
> +1 for same reason.
> 
> However, the patch is wrong, see below:
> 
> $foo = 'foobar';
> 
> $test = <<<"a
> $foo
> a;
> 
> var_dump($test);
> /*
> string(7) "foobar
> "
> */
> 
> $test = b<<<"a"
> $foo
> a;
> 
> /*
> Parse error: syntax error, unexpected $end
> */
> 
> Here's a possible fix:
> - http://felipe.ath.cx/diff/double-quote-heredoc.diff


Thanks for bringing this up, didn't thought about that. I will create a
number of tests to cover that properly.

cu, Lars

---

## #36674 — Pierre Joye — 2008-03-29T11:49:24+00:00

URL: https://externals.io/message/36335#36674 · In reply to: #36335

Hi Lars,


> Hi,
>
>  as we introduce NOWDOC in 5.3 it would be logical to allow a double
>  quoted syntax sister of NOWDOC which acts as HEREDOC (same as for $var =
>  "$var" vs $var = '$var'). Currently we have the following options:

+1 for the record here, I was already in favour of having that in 5.3
in the previous thread.

And to show how great is our new wiki, Lars created a RFC as well:

http://wiki.php.net/rfc/heredoc-with-double-quotes

Thanks for your work!

Cheers,
-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org

---

## #36677 — Lars Strojny — 2008-03-29T12:19:34+00:00

URL: https://externals.io/message/36335#36677 · In reply to: #36666

Hi Felipe, ...,

Am Freitag, den 28.03.2008, 20:28 -0300 schrieb Felipe Pena:
> 2008/3/24, Marcus Boerger <helly@php.net>:
[...]
> Here's a possible fix:
> - http://felipe.ath.cx/diff/double-quote-heredoc.diff

Tested your patch a bit further and it seems to work fine. Created a few
other test cases. Can we close the voting until 00:00h GMT, April, 2nd
2008? If there is a majority for the syntax until then, I will commit
the patch and the test cases.

cu, Lars

---

## #36756 — Stanislav Malyshev — 2008-04-01T20:20:13+00:00

URL: https://externals.io/message/36335#36756 · In reply to: #36652

> As the original proposer of nowdocs, I also give it a +1 for consistency!

"Consistency" must be the most over-used word on the list lately :)
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36757 — Stanislav Malyshev — 2008-04-01T20:21:51+00:00

URL: https://externals.io/message/36335#36757 · In reply to: #36677

> 2008? If there is a majority for the syntax until then, I will commit
> the patch and the test cases.

I think if we want to have a vote it should be explicitly announced as a 
vote, shouldn't it?
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36760 — Lars Strojny — 2008-04-01T21:36:41+00:00

URL: https://externals.io/message/36335#36760 · In reply to: #36757

Hi,

Am Dienstag, den 01.04.2008, 13:21 -0700 schrieb Stanislav Malyshev:
> > […]
> 
> I think if we want to have a vote it should be explicitly announced as a 
> vote, shouldn't it?

OK, fine. From now on this is an official vote. There is no need to vote
again if you did it before, but please raise you voice if you did not.
So let's extend the period until Friday, 4th April 2008, 0:00h CET.

cu, Lars

---

## #36761 — Christopher Jones — 2008-04-01T22:49:48+00:00

URL: https://externals.io/message/36335#36761 · In reply to: #36760

Lars Strojny wrote:
> Hi,
> 
> Am Dienstag, den 01.04.2008, 13:21 -0700 schrieb Stanislav Malyshev:
> > […]
> 
> OK, fine. From now on this is an official vote. There is no need to vote
> again if you did it before, but please raise you voice if you did not.
> So let's extend the period until Friday, 4th April 2008, 0:00h CET.
> 
> cu, Lars

+1

-- 
Christopher Jones, Oracle
Email: christopher.jones@oracle.com    Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/   Free PHP Book: http://tinyurl.com/f8jad
Follow me: http://friendfeed.com/ghrd
