Hi,

On Fri, 2008-03-21 at 21:13 +0100, Marcus Boerger wrote:
> Hello Stanislav,
> 
> Friday, March 21, 2008, 9:08:02 PM, you wrote:
> 
> >> However the '<?echo' I mentioned would work. We could also go for something
> >> like '<?phpecho'. I for one would really appreciate it. And I would not
> 
> > <?phpecho is too long. Really, saving one space here isn't worth a 
> > trouble. If we had something short and nice like <?= that'd be good and 
> > would make PHP templates look clean, but doing <?phpecho instead of 
> > <?php echo - how does it make any real difference?
> 
> The thing is that <?php echo would require a ; while <?phpecho wouldn't.
> And if you ronly argument is saving a few keystrokes then we should really
> get rid of short open tags completely. And definitively not making their
> use easier.

You don't need a ; in front of the ?> therefore <?php echo $foo ?>
works, so the only thing "<?phpecho" saves in fact is one character.

The point about <?= is that it is _very_ short. <?=$foo?> can work quite
nice in simple templating stuff ("PHP is a templating language")

I also think that there aren't many people who preprocess "PHP Hypertext
preprocessor" files with XML-Tools, and if they do they won't use <?.
The XML issue I see there is the conflict with XML-PIs like <?xml which
starts PHP's processing. See [1] as a starting point for that. Already
the second result there [2] shows a real life example where the patch
Stas committed might be useful. In a file called "header.php" - which
certainly isn't the main script - the developer made sure that his
script works with both settings, so on the one hand he has to print the
"<?xml" PI using PHP, so there's no problem with short open tags, but
for outputting variables on the other hand he uses the long tags since
one can't rely on the fact that short tags are working. Using the patch
Stas proposed (and committed) this might be made nicer. I could look for
my own code where I had the same problem inside complexer stuff, but I
guess that random example, which took me <5 minutes to find shows the
possible benefit.

So as long as we have open tags I'd like Stas' patch. The only downside
I see are confused users ("Why doesn't that work for the script I have
that in") but well, we have such users for all stuff we do ;-)

Now we have the big issue: Do we want to have short open tags forever?
Well, without tooo much thinking my idea would be to drop "<?" but keep
"<?=", "<?=" shouldn't conflict with <?xml tags in the same file, but
make it simple to do templating using PHP, on the other hand when not
echo'ing stuff you already have to write more soo the four additional
characters ("php ") don't matter that much - especially every decent
editor/ide should be able to give you a completion on that, if you want.
But such a change in the language should go with other breaks to 6.0 or
so.

johannes

[1] <http://google.com/codesearch?hl=en&lr=&q=lang%3Aphp+%3C%5C%3Fphp
+echo+%5B%22%27%5D%3C%5C%3Fxml&btnG=Search>
[2] <http://google.com/codesearch?hl=en&q=+lang:php+%3C%5C%3Fphp+echo+%
5B%22%27%5D%3C%5C%3Fxml%22
+show:r_a97k72yKQ:0ofXUwlCDds:HkOUVl3hPgM&sa=N&cd=2&ct=rc&cs_p=http://managedtasks.com/wpthemes/gespaa_v2.zip&cs_f=gespaa_v2/header.php#first>



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to