Is using php short tags in views of yii extensions ok?

Is using php short tags in views of yii extensions ok?

I mean <?= and <? instead of <?php echo and <?php

I don’t wont to use ugly long php tags in views & using of alternative templates in extensions is bad idea too. But i know that some people think that php short tags is bad practice too.

Better go with the long approach for max compatibility. In some environments short tags are disabled (by default).

// Example: http://stackoverflow.com/questions/2476072/tags-not-working-in-php-5-3-1

code completion is handy in this respect at least. I have my editor set to fire of the ‘php’ and closing ‘?>’ as soon as I type ‘<?’

~thinkt4nk

It depends from the host, is not a question of best/worst practice.

I advice you to test immediatly if on the host where your work will be hosted the php short tags are accepteded too, if it is, you can use shor tags.

Keep in mind that, if in some remote future you will move the project to another host (wich will not support the shor tags), you will got a bad week…

Zaccaria, short php tags was always accepted on all hosts which was used by me ever :).

The question is about good/bad practice to publish yii extensions with short tags. I like short tags very much and I think about perspective to rewrite all my code that i want to publish. And this perspective demotimates me little bit

I was using short tags for a long time, but now I prefer <?php … ?>, because I see many people use it and almost every one in Yii projects. I think more people will be happy to see non-short tags in your extensions :)

On most of the host I’ve worked on, short tags was off.

Using full php tags ensures maximum compatibility.

And full tags makes php code stand out more than short tags does, of course.

Another reason for using full tags.

Most PHP coding guide-lines recommend using full php tags. ;)

I quote andy_s and jacmoe, if you want to publish something, better to use full tags for compatibility.

That doesn’t mean that they are always accepted… this is an option in the php.ini file… so it depends from the administrators of the server where you are hosting if it will be enabled… That’s why it’s safer to go with the long tags, that works anytime…

Ok, thanx, I decide to not use php short tags in extensions )

using short tags is a big no no. It has been off by default in php since 5.3 or so. In fact, I think they were even tabled as being deprecated for a while.