Why Use the Universally Accepted PHP Start & End Tags?

Believe it or not, but there is PHP programming code that will not work on every installation. This is often a big problem for the developer. Code that is working correctly on the developers computer, and on the web server, may not work on other web servers.

The start and end tags are the culprit. The following tags are most widely used when developing code. These are available with a default installation of PHP.

Line 1:<?php

Line 2:?>

Line 1 is the start tag. It tells the PHP interpreter to start processing the program. Line 2, is the end tag, it tells the interpreter to stop processing the program. There are 2 other tags to be aware of. These are not enabled by default. They require you to change the settings in the php.ini file

Note: php.ini is a text file that holds the configuration settings for the PHP engine. Once these are changed, the web server must be restarted for the changes to be accepted.

Short Tags:


echo ‘this is a short tag’;


These are enabled with the ‘short_open_tag’ directive found in the php.ini file.

ASP Tags:


echo ‘this is an ASP tag’;


These are enabled with the ‘asp_tags’ directive found in the php.ini file.

Why would you choose one of the over?

A good developer is always looking for ways to save time. One tactic is to write less code. Beginners do not always know how to write less, like the more advanced developers. Advanced developers use shortcuts wherever they can.

One thing they do to reduce the amount of words in the program by typing:

Even though it is only three characters less (p-h-p). Not typing 3 characters adds up over time.

This is not a good idea. In the short term it may work. But a good developer must always be thinking about the future. How will the code grow, where will it end up.

As a website matures, so does the programming code. As a site gets larger, it is ofter moved to a new web server. The problem is that all web servers are not setup the same way. If short tags are enabled in the beginning. They may not be enabled on the next web server. Do you see the problem.

Bottom Line: Use the universally accepted PHP tags to ensure the success of your web programming project

Source link