On Fri, 2010-06-11 at 01:34 +0300, Ahmed Mohsen wrote:

> I know that i should use the full open tag in php <?php ?> but i want to 
> know if its good to use this tag <?=$name?> instead of <?php echo $name ?>

Depends who you ask, there was a discussion of this on the list a while
back, and the result was pretty split 50/50. Personally I think it's a
bad idea, as those tags only work when short_tags are turned on, which
itself causes problems with outputting XML from PHP. Yes it saves a
little bit of typing, but with a decent IDE you can set up a shortcut
for that sort of thing anyway, negating the extra seconds spent on a
large project by typing the echo statement.

There is also a potential issue when you move your code to a different
server, as short tags are not enabled by default as of PHP 5.

But, like I said, if you ask someone else, you'll likely get a different
opinion on this issue.

If you're the only one using this code, and the server is in your
control, then it's down to what you prefer to use. If the codebase is
shared, or the hosting is not in your control (shared hosting, etc) then
it's probably best to stick to the regular <?php echo $name ?> format.


Reply via email to