Skip to main content

PHP opening Tags

PHP delimiters are nothing but the open close tags to enclose PHP script. PHP code can be parsed if and only if it is enclosed with these delimiters.
There are various set of delimiters to recognize PHP code. These are as listed below.
  1. <?php … ?> – It is most probably used delimiters and also preferable, since, PHP code enclosed with in <?php .. ?> could be recognized with other PHP servers independent of the tag related configuration directives.
  2. <script language=”php”></script> – This will also work anywhere, like <?php … ?>.
  3. <? … ?> – This is called as PHP short tags which will work based on the value set with short_open_tag directive of PHP configuration file.
  4. <?=..;?> – This is also short form of denoting PHP code, but used as an alternative representation of PHP print statement.
  5. <% … %> or <%=;%>   – This is the delimiters for writing Active Server Pages(ASP) code. But it will be used for PHP code if and only if the asp_tags directive is enabled.

Short_open_tag in PHP Language Configuration

This directive is used to specify whether the short form for PHP delimiters, that is, <?…?> , is allowed or not. This PHP language option will be set with ON/OFF values and the default value is ON. When it is set as ON, then it is allowed to use the short form (<?…?>) to write PHP code which will be recognized by PHP parser. If it is set to OFF, then the PHP code can not be parsed.
This method of writing PHP program by enclosing it with <? and ?> is not recommended programming practice. Because, if we launch our code that contains <? and ?> open, close tags, into another PHP server, where the short_open_tag directive is not enabled, then the code will not work on that server.
Though PHP short tags are not portable among different servers, still they are allowed for providing backward compatibility.
This form is used to print something to the browser. For example, a PHP echo statement can be written as follows.
$statement = "PHP Open and Close Tags";
<?=$statement;?>
From the above list of ways to represent PHP tags, the fourth possible form, that is, <?=;>was also included with this constraint depends on the value of short_open_tag directive as of earlier PHP versions. But, as of PHP version 5.4, this form will also be portable like first two delimiters, for launching our code having this notation, into another server.

asp_tags Option

This option is used to allow to recognize PHP code enclosed with the open close tags used in Active Server Pages (ASP) scripting, that is like, <%…%>.
We can search for this tag in PHP.ini file. If it is enabled by having the value ON, then the PHP scripts inside the open close tags, <%,%> will be executed, and also, the alternative ASP print statement representation, like, <%=;%> also allowed. Otherwise, the script including asp tags will be displayed in the browser.
As like PHP short tags <? and ?>, asp style tags also depends on PHP configuration settings. So, this form of tags is also not preferable to develop PHP projects to be launched in another server, because of the lack of portability.
Note:
  • From the above list of PHP delimiters, short tags and the ASP style delimiters are not recommended a method to represent PHP code, since they are depending on configuration settings.
  • Even though, <script language=”php”></script> is portable, it is also not widely used for avoiding confusion in separating PHP code embedding it while embedding it HTML or XML content.

Comments

Popular posts from this blog

Create facebook messenger chatbot using PHP

Chatbots are the latest sensation in social media communication channels. These automated chat systems are especially build to receive vistiors on social media chats and provide basic information to the visitors about your business. This information could include event schedules, product information, latest deals, store offers and general information about the brand. Entrepreneurs and brand marketers employ chatbots to handle the bulk of chats queries. This way, a large number of queries could be easily handled with minimum costs. Chatbots help reduces the dependence on human customer service representatives (CSR). These chatbots vet out common queries so that the human CSR cold focus on queries that require processing of multiple information sources. Since chatbots steer all conversation toward a pre-set direction, it is easy and time-efficient to use these chatbots instead of human CSR. In this article, I will create a simple Facebook chatbot that could carry out an

Build chatbot with node js and react js

User Experience is given a lot of attention while building any application these days. More and more brands are leveraging chatbots to service their customers, market their brand, and even sell their products. There are a lot of awesome tools out there which helps in building an intelligent bot very easily like Google’s DialogFlow, Amazon Lex, etc, most of which implement their own Natural Language Processing (NLP) logic. However, in some cases, we don’t really need an intelligent bot. Whenever we have a small application having a limited set of options to choose from, it’s not really necessary to use NLP based tools like Google’s DialogFlow. You need to integrate with them (which is pretty easy though), and you need to make a network call to get the results. Instead, you would want to define your rules locally in those cases. Here we will build a simple chatbot using React Simple Chatbot library and add it to our pizza-builder app using which we can build ou

Now About PHP Info

Have you ever heard about phpinfo(). Yes, this function is used to know about configuration details of PHP installed in our machine. Such detailed information returned by this phpinfo() includes platform information, PHP and server environment, HTTP header information, PHP core details like version and directives status, License information and etc. phpinfo() function has an optional argument. If this function is called with no argument, then will display all information. We can check it by executing the following code. <? php phpinfo (); ?> We can also request specific details to be displayed to the browser by passing available constants to this function. Following list shows such available options. INFO_GENERAL – This will return information about the platform, compiler, architecture, API and etc. INFO_CREDITS – This option provides a hyperlink which shows details about authors, documentation, QA and infrastructure team. INFO_CONFIGURATION – Disp