There are a number of ways to escape between PHP and output (usually HTML) mode. Personally I recommend sticking with the traditional <?php style. One method that can cause problems is the so called ‘short tag’ style – <? and I recommend avoiding it.
So how do you know if there are PHP short tags being used some where in your code? I use grep to search for them: grep -rn "<?[^p]" *
I use <?php tags, but what is problem with shorttags? I never found explanation.
The <?php tags are the only ones that you can be sure will work across all PHP installs. That’s the big one for me.
Thanks for the tip, Joseph. Very useful—I’ve added it to my arsenal of theme testing checks.
No problem, happy to hear it helped.
I like to use short tags for personal and client work, when I know I have full control of the hosting environment. I’ll use full php tags for public and open source code.
It kinda sucks that short tags aren’t enabled by default. is so much nicer than . Less typing, and readability is better.
The situation where you just need to do a simple echo would be nicer, but could potentially be accomplished with <?php= $some_var ?> – hopefully PHP core will support that syntax one day.
Pingback: Reminder: Don’t Use the Short PHP Open Tag – — Konstantin KovsheninKonstantin Kovshenin