• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » PHP » PHP: Why it is not advisable to use short tags …
Next →
← Prev

PHP: Why it is not advisable to use short tags …

By Dinesh Thakur

As you all know, any PHP script must be surrounded by specific tags. They allow the interpreter to know where in the file is PHP code to execute. On ecomputernotes.com, all presented scripts use the <? Php and ?>; and it is not by chance …

We’ll be covering the following topics in this tutorial:

  • The various PHP code boundary markers
  • Why choose <? Php and ?> ?
  • Introduction to an XML file

The various PHP code boundary markers

There are indeed several syntaxes PHP tags. Here they are detailed in the following list:

• <? php and ?> (formal language tags)
• <? and ?> (very short tags used by novice webmasters)
• <? = And ?> (Rarely used)
• <% And %> (tag from the ASP language – rarely used)
• <script language = “php”> and </ script?> (rarely used)

Why choose <? Php and ?> ?

Simply becaufe tags <? Php and ?> Ensure full portability on all servers and all versions of PHP. These are the tags default PHP.

However, “short-tags” could prevent the execution of your scripts for the following two reasons:

• The server that hosts your php pages disables the use of these markers by the php.ini directive short_open_tags placed to off.
• It there’s confusion with the opening tag of an XML file.

Indeed, an XML file begins with the following syntax:

Introduction to an XML file

<? xml version = “1.0” encoding = “utf-8” standalone = “yes”?>

Note the presence of the short tag <? at the beginning of the code and?> at the end. When reading the file, the interpreter PHP will attempt to execute this line (thinking it’s PHP) and return a parsing error similar to the one below:

Syntax error: conflict between the interpreter and the PHP XML file
Parse error: syntax error, unexpected T_STRING in /Applications/MAMP/htdocs/CodePHP/xml.php on line 1

The only way to solve this problem is to generate the XML code using an echo statement () for example.

Solution to avoid this conflict
<? php
echo '<? xml version = "1.0" encoding = "utf-8" standalone = "yes"?> "," \ n ";
?>

You’ll also like:

  1. Why it is not advisable to use short tags …
  2. JSP Directive tags | Types of Directive tags
  3. Short Note on Single Linked List
  4. PHP Cookies
  5. PHP Sessions
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

PHP Tutorials

PHP Tutorials

  • PHP - Home
  • PHP - Features
  • PHP - Magic Methods
  • PHP - Imagefilter
  • PHP - Arrays Numeric
  • PHP - Sessions
  • PHP - Forms Processing
  • PHP - clone()
  • PHP - Cookies
  • PHP - Variable Types
  • PHP - First program
  • PHP - call()
  • PHP - Iterator interface
  • PHP - Imports files
  • PHP - Exception Handling
  • PHP - set() and get()
  • PHP - Install MAMP
  • PHP - Functions
  • PHP - Constants Types
  • PHP - Comments Types
  • PHP - OOP's
  • PHP - OOps Use
  • PHP - PHP Code & Redirect 301
  • PHP - Control structures
  • PHP - Abstract Classes
  • PHP - Control structures
  • PHP - Classes
  • PHP - MySQL NULL values
  • PHP - Methods Visibility
  • PHP - Operator Types
  • PHP - Short tags Not use
  • PHP - Object and class
  • PHP - Secure Passwords

Other Links

  • PHP - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW