[sf-perl] PHP line-ending question

Rich Morin rdm at cfcl.com
Sun Mar 5 09:51:47 PST 2006

At 8:17 AM -0800 3/5/06, David Fetter wrote:
> I tried to reproduce this at <http://fetter.org/~shackle/foo.php>
> and got something different, i.e. all on the same line.  Could you
> post an self-contained PHP file that reproduces the problem as you
> see it?


> PHP is training wheels without the bike.

I cheerfully admit that PHP is inconsistent, quirky, etc.  OTOH, it
is often available in places where Ruby isn't and it can be used as
a macro processor (like Erb) in various useful places and manners:

  Using PHP as a Macro Pre-processor

  Polyglot Programming

BTW, I've actually found some things in PHP that Perl should have.
For example, it allows hashes to have a default sort order.  In
Perl, I have to simulate this by doing:

  foreach my $key (sort(keys(%hash))) {


Here's the requested code and output...

rdm at cerberus [~/Work/PHP] 16: cat plex
#!/usr/bin/env php
# plex - PHP line-ending example

<? $a = 'some text';
   $b = 'more text.';

   This is <?= $a ?>.
   This is <?= $b ?>
   That's enough...
rdm at cerberus [~/Work/PHP] 17: plex
# plex - PHP line-ending example

   This is some text.
   This is more text.   That's enough...
rdm at cerberus [~/Work/PHP] 18:
Technical editing and writing, programming, and web development:

Contact information: rdm at cfcl.com, +1 650-873-7841

More information about the SanFrancisco-pm mailing list