Re: Short tag: why is it bad practice?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

     So, as I've understood, the only issue with <? // blah-blah ?> is
the <?xml version 1.0?> thing?
Thanks!



-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

------------ Original message ------------
From: Daevid Vincent <daevid@xxxxxxxxxx>
To: php-general@xxxxxxxxxxxxx
Date created: , 9:55:23 PM
Subject:  Short tag: why is it bad practice?


      > -----Original Message-----
> From: Joshua Kehn [mailto:josh.kehn@xxxxxxxxx]
> Sent: Tuesday, May 10, 2011 8:19 AM
> To: Andre Polykanine
> Cc: php-general@xxxxxxxxxxxxx
> Subject: Re:  Short tag: why is it bad practice?
> 
> On May 10, 2011, at 11:11 AM, Andre Polykanine wrote:
> 
> > Hi everyone,
> > Many  times  I heard that the following two peaces of code are written
> > in a bad manner:
> > 1.
> > <?
> > echo "Hello, world!";
> > ?>
> >
> > 2.
> > <form action="script.php" method="post">
> > <p>Your   e-mail:   <input   type="text"   id="uemail"   name="uemail"
> > value="<?=$f['Email']?>"></p>
> > ...
> > </form>
> >
> > As for now, I use both quite often. Why is this considered not kosher,
> > I mean, good coding practice?
> > Thanks!
> >
> > --
> > With best regards from Ukraine,
> > Andre
> > Skype: Francophile
> > Twitter: http://twitter.com/m_elensule
> > Facebook: http://facebook.com/menelion
> 
> 
> Because short tags aren't always enabled and can cause things to break
when
> deploying code to different environments. Best practice dictates that your
> code should be as environmentally independent as possible.
> 
> It's another few characters, why neglect it?

This is always a source of confusion.

http://www.bin-co.com/php/articles/using_php_short_tags.php

<?= $foo ?> is generally NOT what the short tags controversy are about.

It's the use of <? Some php here ?>  vs. <?php some php here ?>

While it is true that the 'short_open_tag' directive enables both (for some
stupid reason), the issue is that it's poor form to use JUST <? And not
<?php just as it's a bad idea to use <% %> (asp tags).

Using <?= is perfectly fine and in my personal and professional opinion,
preferred to the uglier <?php echo $foo; ?> way

This topic was very heated when the core PHP developers were going to remove
the <? Form all together in future PHP 6  versions and everyone got their
panties in a bunch because they assumed it meant the <?= form too (which it
did not).

http://php.net/manual/en/ini.core.php

http://www.php.net/~derick/meeting-notes.html#remove-support-for-and-script-
language-php-and-add-php-var





-- 
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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux