Daevid Vincent | 1 May 2007 01:33
Favicon

RE: What does "<<<" mean?

> echo "BROWSER: " . $_SERVER['HTTP_USER_AGENT'] . "\n";

I've always had problems with heredoc when I try using arrays like that. I
will either pull them into a straight $foo, or use the ${} thing.

> echo <<<EOF
> BROWSER: $_SERVER[HTTP_USER_AGENT]
> EOF;

Isn't that form (sans quote marks) deprecated and frowned upon?

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Greg Donald | 1 May 2007 02:03
Picon
Gravatar

Re: What does "<<<" mean?

On 4/30/07, Daevid Vincent <daevid <at> daevid.com> wrote:
> > echo <<<EOF
> > BROWSER: $_SERVER[HTTP_USER_AGENT]
> > EOF;
>
> Isn't that form (sans quote marks) deprecated and frowned upon?

<?php

error_reporting( E_ALL );

echo <<<EOF
BROWSER: $_SERVER[HTTP_USER_AGENT]
EOF;

Why would cleaner, perfectly error free code be frowned upon?

-- 
Greg Donald
http://destiney.com/

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Brian Seymour | 1 May 2007 02:06

RE: What does "<<<" mean?

Heredoc is truly a great thing. You'll learn to love heredoc whenever you
have tons of stuff you need to print instead of escaping php. A great
example is output that comes from classes, where you can't break the class
into multiple code blocks. Just don't forget that heredoc end part has to be
on the very next line with no whitespace to start. Confusing at times.

Cheers!
-BRIAN

>Ok, let's gather some stats to see how many people actually use the  
>heredoc syntax. I created this quick little form to gather the data.  
>It's takes 2 seconds (literally) - vote here:

>http://thril.uark.edu/heredoc/

>I'm interested in knowing if this is used a lot. If it is, then I may  
>consider tying it into my code (if it calls for it).

>~Philip

>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Paul Novitski | 1 May 2007 02:18

Re: What does "<<<" mean?

At 4/30/2007 03:38 PM, Philip Thompson wrote:
>Ok, let's gather some stats to see how many people actually use the
>heredoc syntax. I created this quick little form to gather the data.
>It's takes 2 seconds (literally) - vote here:
>
>http://thril.uark.edu/heredoc/
>
>I'm interested in knowing if this is used a lot. If it is, then I may
>consider tying it into my code (if it calls for it).

I recommend that you to make your decision about using heredoc based 
on whether the syntax itself makes good sense to you, not based on 
which number or percentage of other programmers use it.

I love using heredoc and I don't give a rat's ass if there are only 
three other people in the world who use it.  It absolutely makes 
sense to me, helps me write better code with fewer errors and that's 
much easier to read.  I know from previous discussions of this topic 
that it gives some people the freakin' heebee-jeebies.  That's fine; 
different strokes; doesn't matter.  It's just one tool.

I use heredoc mostly for SQL queries, for html blocks, for inline 
html assembly, and for other circumstances in which I'm merging 
literals & variables.  If a statement gets messy with too many 
concatenations, I'll use heredoc.  I use heredoc for much the same 
reasons I like to separate data from logic in separate files.  The 
next best thing to importing text is to heredoc it in the script 
itself.  Also heredoc can be a quick & dirty way of roughing out a 
script to get the logic right before exporting the text to a separate file.

(Continue reading)

Richard Davey | 1 May 2007 02:19
Picon

Re: What does "<<<" mean?

Greg Donald wrote:

> On 4/30/07, Daevid Vincent <daevid <at> daevid.com> wrote:
>> > echo <<<EOF
>> > BROWSER: $_SERVER[HTTP_USER_AGENT]
>> > EOF;
>>
>> Isn't that form (sans quote marks) deprecated and frowned upon?
> 
> <?php
> 
> error_reporting( E_ALL );
> 
> echo <<<EOF
> BROWSER: $_SERVER[HTTP_USER_AGENT]
> EOF;
> 
> Why would cleaner, perfectly error free code be frowned upon?

I'm not dissing heredoc syntax, it has its uses (now and again) but it's 
far from "clean", especially when embedded deep in classes - the major 
cause being the delimeters insistance on being at the very start of the 
line. It's just *not* pretty IMHO. Certainly not girl code [1]

The frowning surely would be at the mixing of logic and presentation, 
regardless how that mix happens (heredoc, echo, jumping in and out of 
PHP tags, sprintf, etc).

Cheers,

(Continue reading)

Greg Donald | 1 May 2007 02:42
Picon
Gravatar

Re: What does "<<<" mean?

On 4/30/07, Richard Davey <rich <at> corephp.co.uk> wrote:
> I'm not dissing heredoc syntax, it has its uses (now and again) but it's
> far from "clean", especially when embedded deep in classes

Classes?  PHP is the absolute worst language to do OO programming in.
If you like OO, move on to ruby or python, you'll be much happier.  Or
you can wait around until PHP fully (d)evolves into Java.

> the major
> cause being the delimeters insistance on being at the very start of the
> line.

All parts of a heredoc statement do not have to be right justified,
only the closing line.

> It's just *not* pretty IMHO. Certainly not girl code [1]

Mmmm..  girls..  coding..  :)

> The frowning surely would be at the mixing of logic and presentation,

Sounds like you got MVC-itis.  PHP can't really help with that since
it's a templating language.

Try Rubyonrails, it's the best cure for the MVC itch.

> regardless how that mix happens (heredoc, echo, jumping in and out of
> PHP tags, sprintf, etc).

I love me some heredoc syntax:
(Continue reading)

Greg Donald | 1 May 2007 02:44
Picon
Gravatar

Re: What does "<<<" mean?

On 4/30/07, Greg Donald <gdonald <at> gmail.com> wrote:
> All parts of a heredoc statement do not have to be right justified,
> only the closing line.

I meant my other right, the one on my left.  Sorry.

-- 
Greg Donald
http://destiney.com/

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Robert Cummings | 1 May 2007 02:50
Favicon
Gravatar

Re: What does "<<<" mean?

On Mon, 2007-04-30 at 19:42 -0500, Greg Donald wrote:
> On 4/30/07, Richard Davey <rich <at> corephp.co.uk> wrote:
> > I'm not dissing heredoc syntax, it has its uses (now and again) but it's
> > far from "clean", especially when embedded deep in classes
> 
> Classes?  PHP is the absolute worst language to do OO programming in.
> If you like OO, move on to ruby or python.

You sissy, Ruby and Python suck. One baseless statement deserves
another. Feel free to back up your statement with verifiable proof.

> , you'll be much happier.  Or
> you can wait around until PHP fully (d)evolves into Java.

Unlikely.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--

-- 
(Continue reading)

Micky Hulse | 1 May 2007 03:07

Re: What does "<<<" mean?

Greg Donald wrote:
> Try Rubyonrails, it's the best cure for the MVC itch.

Django framework is pretty nice too. :)

-- 
Wishlists: <http://snipurl.com/1gqpj>
    Switch: <http://browsehappy.com/>
      BCC?: <http://snipurl.com/w6f8>
        My: <http://del.icio.us/mhulse>

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Daevid Vincent | 1 May 2007 04:05
Favicon

RE: sloppy use of constants as strings. WAS: What does "<<<" mean?

> > > echo <<<EOF
> > > BROWSER: $_SERVER[HTTP_USER_AGENT]
> > > EOF;
> >
> > Isn't that form (sans quote marks) deprecated and frowned upon?
> 
> <?php
> 
> error_reporting( E_ALL );
> 
> echo <<<EOF
> BROWSER: $_SERVER[HTTP_USER_AGENT]
> EOF;
> 
> Why would cleaner, perfectly error free code be frowned upon?

http://us2.php.net/manual/en/language.types.array.php
"A key may be either an integer or a string. If a key is the standard
representation of an integer, it will be interpreted as such (i.e. "8" will
be interpreted as 8, while "08" will be interpreted as "08")."

I was always under the impression that using:

	$_SERVER[HTTP_USER_AGENT] or $foo[myindex]

Was "bad" compared to the proper way of:

	$_SERVER['HTTP_USER_AGENT'] or $foo['myindex']

Just like it's:
(Continue reading)


Gmane