what is the <% in the php files and how it should compile?

203 views Asked by At

I have new sample.php file that is it active on a cpanel (Apache server) and it is work correctly on that cpanel, I don't know how it is working! because it is PHP file but it is using <% instead of <?PHP in it's php syntax and %> instead of ?> and <%= instead of <?PHP echo.


can you tell me what is the <% and how I can enable it in my cpanel?

1

There are 1 answers

1
Jacob S On BEST ANSWER

<% are called "asp-style tags".

If you have access to the php.ini, set asp_tags = Off or asp_tags = 0 to asp_tags = On or asp_tags = 1 respectively.

To temporarily enable asp-tags for a script, you can add <?php ini_set('asp_tags',1) ?> to the beginning of the file, but this is less than ideal.

The alternative would be to replace each <% with <?php and each %> with ?>. If you are using short_tags, you can replace <%, %>, and <%= with <?, ?>, and <?=, respectively.