Finding PHP Short Tags

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]" *

7 thoughts on “Finding PHP Short Tags

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

  2. Pingback: Reminder: Don’t Use the Short PHP Open Tag – — Konstantin KovsheninKonstantin Kovshenin

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>