About this question
I recently found a couple of PHP servers where short_open_tag is set to off. I would like to know if there is any security reason to set short_open_tag off.
I recently found a couple of PHP servers where short_open_tag is set to off. I would like to know if there is any security reason to set short_open_tag off.
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask Cyber Security Expert
Answered on Apr 8, 2022
There are security reasons for never using short_open_tag in your code.
Your code could easily end up on a server with short tags off, through a migration or perhaps some misconfiguration. If you have been using short tags to mark what is PHP code and what is not, suddenly your PHP will be interpreted as content and served as is. That could leak all sorts of secrets. But does this mean you should turn the feature off? On the one hand, it's a great way of stopping your developers from using them. On the other hand, if you move in code from somewhere else it exposes you to the problem mentioned above. There is discussion within the PHP community about deprecating short tags.
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Step-by-step Cyber Security guides from industry experts
Common Cyber Security interview questions, answered
Guides, tips and career advice on Cyber Security from JanBask experts.
Cyber Security How to Prepare for SOC Analyst Certification: A Practical Study Guide
Learn how to prepare for SOC analyst certification with a practical study plan. Compare CySA+, SC-200 and BTL1, build hands-on…
Cyber Security How to Prepare for Penetration Testing Certification: A Practical Study Guide
Learn how to prepare for penetration testing certification: compare PenTest+, OSCP, eJPT and CEH, build a study plan, and…
Cyber Security Is Penetration Testing a Good Career in 2026? Pay, Demand, Pros & Cons
Is pen testing a good career? See honest data on demand, pay, entry barriers, AI’s impact, and whether penetration testing is…
Cyber Security GRC Analyst Salary: How Much Can You Earn in 2026?
GRC analyst salary guide for 2026: see average pay, salary range by experience, location, and certifications, plus how to grow…