Allow ASP Style Short_Open_Tag in PHP.ini


In ASP, the code is wrapped with <% … %> to distinguish from HTML code. The code is executed dynamically at server side before sending pure HTML to the client browser. In ASP, you can output a single variable by using

<% = "Hello, World" %>

instead of

<% Response.Write "Hello, World" %>

In PHP, the tags using is <?php .. ?> where the ?> is not always necessary for example, if there are no content after the tag (end of file), then it can be omitted. If you want to output a single variable, in ASP style, you can use

1
<? = "Hello from PHP"; ?>
<? = "Hello from PHP"; ?>

Instead of using full tag.

1
<?php echo "Hello from PHP"; ?>
<?php echo "Hello from PHP"; ?>

Recently, a server PHP website has been migrated to Amazon cloud server, but the following seems not showing the correct value.

shorttag-php-off Allow ASP Style Short_Open_Tag in PHP.ini apache server php web programming webhosting

Incorrect showing shorttag in PHP

The cause is that the short_open_tag is set to off in php.ini where is usually located at /etc/php.ini (run command locate php.ini).

You would need root admin to edit the php.ini where you can search and locate short_open_tag = Off in the file and set it to short_open_tag = On.

Restart the apache server by issuing command e.g.

1
sudo service httpd restart
sudo service httpd restart

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
339 words
Last Post: RandomFloatRange Function in Delphi/Object Pascal
Next Post: How to Get File Size in Bytes using Delphi / Object Pascal ?

The Permanent URL is: Allow ASP Style Short_Open_Tag in PHP.ini

Leave a Reply