Re: Re: PHP in HTML code

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

 



On Tue, Mar 16, 2010 at 7:06 PM, Ashley Sheridan
<ash@xxxxxxxxxxxxxxxxxxxx>wrote:

> On Tue, 2010-03-16 at 23:42 +0100, Rene Veerman wrote:
>
> > maybe adding a <?php= as equivalent to <?= and <?php echo ,
> > then deprecating <?= would be useful.
> >
> > On Tue, Mar 16, 2010 at 7:18 PM, tedd <tedd.sperling@xxxxxxxxx> wrote:
> > > At 5:54 PM +0000 3/15/10, Jochem Maas wrote:
> > >>
> > >> Op 3/13/10 3:49 PM, Jorge Gomes schreef:
> > >>>
> > >>>  First of all, i recommend the use of normal php tags (<?php ...  ?>)
> > >>> because
> > >>>  the short tags are atm marked as* **DEPRECATED*.
> > >>
> > >> that's a documentation error.
> > >>
> > >>>
> > >>>  You should also echo your values to the page, instead using the
> shortcut
> > >>> <?=
> > >>>  (stop being a lazy ass! :P):
> > >>
> > >> it's not lazy, it's succinct and much easier to read (once you know
> what
> > >> it means),
> > >
> > > Yes, but like all web languages, they don't live in a vacuum -- they
> must
> > > play well with others to survive. Programming is dynamic not static.
> > >
> > > While using "<?=" identifies what follows "to you", it doesn't "to
> others"
> > > and therein lies the problem. If XML (and possibility others) don't
> accept
> > > the short term tag, then why use it?
> > >
> > > Using "Standards" like this help promote better communication between
> all
> > > languages -- what's wrong with that? Simply put, either communicate
> better
> > > or don't -- that's your choice -- but your decision is also a
> demonstration
> > > to your client/employer/peers as to your desire to produce the "best"
> > > possible code.
> > >
> > > I look at code containing "<?=" the same way as I see html containing
> tables
> > > and embedded styling for presentation -- "This must be old code OR the
> > > programmer still doesn't get it".
> > >
> > > Cheers,
> > >
> > > tedd
> > >
> > > --
> > > -------
> > > http://sperling.com  http://ancientstones.com  http://earthstones.com
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
>
> I think that would just add to an already confusing situation.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
I'll confess that I work on ASP.Net just as much as PHP (If you must throw
tomatoes, make sure their really ripe so they don't hurt as much ;)  I
appreciate the different tags offered in ASP.Net, as they succinctly provide
some convenient capabilities (one version provides similar capabilites to
PHP's <?=$var_to_echo?>.)

I believe that although they're removing the ASP version of tags (e.g., <%
%>) from PHP 6, they're keeping the short tag option debated in this thread,
and I hope they do.

To say that using short tags is bad form seems quite strong.  Additionally,
saying that XML doesn't accept the syntax is also extreme.  It's not that
XML doesn't accept the short tag.  Actually, PHP's parser is confused by the
XML declaration.  When you work with generating an XML document with PHP, it
only takes one line of code to accommodate PHP's parser.  However, the vast
majority of the time I'm generating XHTML 1 (or now more and more XHTML 5),
and neither of these require the XML declaration for validation purposes.

Additionally, wanting to write less code to perform the same action isn't
necessarily an act of laziness.  Am I lazy for loving the that I can use
simple message passing capabilities in Scala or transactional memory in
Clojure to perform tasks in parallel as opposed to the olden days of dealing
with threads in Java?  When I can type less, maintain clarity, and perform
the same action, I consider it an act of beauty.

When you compare the code samples below, I find that I prefer the short tag
version or the last example when I'm reworking the XHTML, as there's less
code to sift through.  There seems to be a trend in other templating
languages to shorten the amount of typing (e.g., Google Go uses
http://json-template.googlecode.com/svn/trunk/doc/Introducing-JSON-Template.html),
and I hope PHP will continue to keep pace with the trend, too.  That said,
I'm not taking exception with those who don't use the short tag, only with
those who say I shouldn't.

Adam

<section>
    <article>
        <h2><a href="<?php echo $url; ?>"><?php echo $title; ?></a></h2>
        <p>
            <?php echo $description; ?>
            <span><?php echo $date; ?></span>
        </p>
    </article>
    <article>
        <h2><a href="<?= $url ?>"><?= $title ?></a></h2>
        <p>
            <?= $description ?>
            <span><?= $date ?></span>
        </p>
    </article>
    <!--
        This last example is just to show the scheme I use in my own web
framework, which is similar to JSON template
    -->
    <article>
        <h2><a href="{url}">{title}</a></h2>
        <p>
            {description}
            <span>{date}</span>
        </p>
    </article>
</section>

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

[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