Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #9878 > unrolled thread
| Started by | Shelly <sheldonlg@thevillages.net> |
|---|---|
| First post | 2013-06-24 21:02 -0400 |
| Last post | 2013-06-27 12:17 -0400 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.php
strange one Shelly <sheldonlg@thevillages.net> - 2013-06-24 21:02 -0400
Re: strange one Scott Johnson <noonehome@chalupasworld.com> - 2013-06-24 18:10 -0700
Re: strange one Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2013-06-24 21:14 -0400
Re: strange one Shelly <sheldonlg@thevillages.net> - 2013-06-24 21:18 -0400
Re: strange one richard <noreply@example.com> - 2013-06-27 12:17 -0400
| From | Shelly <sheldonlg@thevillages.net> |
|---|---|
| Date | 2013-06-24 21:02 -0400 |
| Subject | strange one |
| Message-ID | <kqaptj$vgn$1@dont-email.me> |
My daughter also does php. She has to fix up some awful code. She came across something that I have never seen before. It goes something like this: $a .= <<<BLAH; What is that <<< ? -- Shelly
[toc] | [next] | [standalone]
| From | Scott Johnson <noonehome@chalupasworld.com> |
|---|---|
| Date | 2013-06-24 18:10 -0700 |
| Message-ID | <kqaqbu$1fb$1@dont-email.me> |
| In reply to | #9878 |
On 6/24/2013 6:02 PM, Shelly wrote: > My daughter also does php. She has to fix up some awful code. She came > across something that I have never seen before. It goes something like > this: > > $a .= <<<BLAH; > > What is that <<< ? > It is a heredoc string. Myself I use it quite often when I am formatting output text with variables for emails and such. Here is the manual on it http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
[toc] | [prev] | [next] | [standalone]
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Date | 2013-06-24 21:14 -0400 |
| Message-ID | <S96yt.64696$hw2.28189@newsfe04.iad> |
| In reply to | #9878 |
On Monday 24 June 2013 21:02, in comp.lang.php, sheldonlg@thevillages.net wrote: > My daughter also does php. She has to fix up some awful code. She came > across something that I have never seen before. It goes something like > this: > > $a .= <<<BLAH; > > What is that <<< ? It is the start of a "heredoc" http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc Specifically, the word immediately adjacent to the right of the <<< (in your case, the word BLAH) is taken as a sentinal, and all lines between the line containing the start of the heredoc (the <<<BLAH line) and the first line that contains the sentinal word are treated like a single string. Thus <<<BLAH this is a test one two three four five six BLAH; is treated as a single string consisting of "this is a test\none two three\nfourfive\nsix\n" -- Lew Pitcher "In Skills, We Trust"
[toc] | [prev] | [next] | [standalone]
| From | Shelly <sheldonlg@thevillages.net> |
|---|---|
| Date | 2013-06-24 21:18 -0400 |
| Message-ID | <kqaqr0$3ou$1@dont-email.me> |
| In reply to | #9880 |
Thank you Lew and Scott. On 24/06/2013 21:14, Lew Pitcher wrote: > On Monday 24 June 2013 21:02, in comp.lang.php, sheldonlg@thevillages.net > wrote: > >> My daughter also does php. She has to fix up some awful code. She came >> across something that I have never seen before. It goes something like >> this: >> >> $a .= <<<BLAH; >> >> What is that <<< ? > > > It is the start of a "heredoc" > http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc > > Specifically, the word immediately adjacent to the right of the <<< (in your > case, the word BLAH) is taken as a sentinal, and all lines between the line > containing the start of the heredoc (the <<<BLAH line) and the first line > that contains the sentinal word are treated like a single string. > > Thus > <<<BLAH > this is a test > one two three > four five > six > BLAH; > > is treated as a single string consisting of > "this is a test\none two three\nfourfive\nsix\n" > -- Shelly
[toc] | [prev] | [next] | [standalone]
| From | richard <noreply@example.com> |
|---|---|
| Date | 2013-06-27 12:17 -0400 |
| Message-ID | <mwrrxzisnuwe.6rizs2d7r97w$.dlg@40tude.net> |
| In reply to | #9880 |
On Mon, 24 Jun 2013 21:14:25 -0400, Lew Pitcher wrote: > On Monday 24 June 2013 21:02, in comp.lang.php, sheldonlg@thevillages.net > wrote: > >> My daughter also does php. She has to fix up some awful code. She came >> across something that I have never seen before. It goes something like >> this: >> >> $a .= <<<BLAH; >> >> What is that <<< ? > > > It is the start of a "heredoc" > http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc > > Specifically, the word immediately adjacent to the right of the <<< (in your > case, the word BLAH) is taken as a sentinal, and all lines between the line > containing the start of the heredoc (the <<<BLAH line) and the first line > that contains the sentinal word are treated like a single string. > > Thus > <<<BLAH > this is a test > one two three > four five > six > BLAH; > > is treated as a single string consisting of > "this is a test\none two three\nfourfive\nsix\n" thanks. I had read this about heredoc and was a tad confused on the explanation. Your explanation clears it up.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web