Re: Newbie question about <?= ?>

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

 



Okay, after thinking about it, and looking at the replies, it seems as
though there is only one situation where the short tags break things, and
that's in XML with the <? ?> pair being valid for XML.

Yes, enabling the short tags is in the ini file, but is it on by default
and require effort to change?

That's the real question, I think.  Not, why shouldn't I use them the way
they are, but why is it that the <?= ?> tag isn't designed into the
language to be acceptable?

Honestly, the <? ?> pair just feels a little lazy, since all you save are
the 4 characters "php ", and all the code inside is the same.  The <?= ?>
tag gives you 7 characters free and does something unique.

The situation I think of using it the most in is something such as:
  <li><a href="<?= $post->permLink; ?>">...</a></li>

Which looks cleaner, in my opinion, than:
  <li><a href="<?php print $post->permLink; ?>">...</a></li>

Not a whole lot larger, no, and perhaps you might say, Well, the second
way is more explicit!  Yes.

Also, shouldn't it be possible to check for <?= ?> and, based on the '='
there, pop out of the parser if it comes across <?xml...?> ?

Cheers,
Mike

> As was said before, the major reasons for not using short tags are:
>
> 1) Not everyone has access to the ini file, and might not be able to use
> short
> tags.  If you're releasing your code to the public, you want to work in as
> many places as possible, so then you should use <?php instead.
>
> 2) when using XML files, they use <?xml, and the <? is recognized as the
> start
> of a PHP block, but the following syntax will be correct and your code
> will
> fail.  I have seen that someone suggested having PHP recognize <?xml as
> not
> being a PHP short tag, but I don't remember where off the top of my head.
>
> This does bring up an interesting idea though.  It appears that <?php= is
> not
> valid.  A lot of people use <?= as a sort of templating system instead of
> adding the complexity of smarty or other templating systems (which are
> fine).
> Is it possible, or will it be possible, to use <?php="blah" ?>
>
> --
> Ray Hauge
> Programmer/Systems Administrator
> American Student Loan Services
> www.americanstudentloan.com
> 1.800.575.1099
>

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