• 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 » Why it is not advisable to use short tags …
Next →
← Prev

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. These reserves 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 differentPHP codeboundary markers
  • Why prefer <?php and ?>?

The differentPHP codeboundary markers

• <?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 prefer <?php and ?>?

Simply because the 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 tags with the short_open_tags php.ini directive placed to off.
• There continues to be confusion with the opening tag of an XML file.

In fact, an XML file begins with the following syntax:

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/Tests-PHP/xml.php on line 1 

 

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

Solution to avoid conflict

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

 

I will not change my files still …

 

If you do not intend to change provider, then do not change all your scripts but cons think to adopt this good practice for future applications. You are not
immune to a different configuration of a server (that of a customer for example).

Note for example that the default software EasyPHP.2 banned short tags to force developers to adopt this good practice.

You’ll also like:

  1. PHP: Why it is not advisable to use short tags …
  2. JSP Directive tags | Types of Directive tags
  3. Write Short Note on C-Scan Scheduling
  4. Short Note on Single Linked List
  5. Short Note on Singly Circular Linked List
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 © 2023. All Rights Reserved.