php 文件中的 <% 是什么?应该如何编译?

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

我有新的 sample.php 文件,它在 cpanel(Apache 服务器)上处于活动状态并且在那个 cpanel 上工作正常,我不知道它是如何工作的!因为它是 PHP 文件,但它在 php 语法中使用 <% 而不是 <?PHP 并且 %> 而不是 ?><%= 而不是 <?PHP echo.


你能告诉我什么是 <% 以及如何在我的 cpanel 中启用它吗?

<% 称为 "asp-style tags".

如果您有权访问 php.ini,请将 asp_tags = Offasp_tags = 0 分别设置为 asp_tags = Onasp_tags = 1

要临时启用脚本的 asp 标签,您可以将 <?php ini_set('asp_tags',1) ?> 添加到文件的开头,但这并不理想。

备选方案是将每个 <% 替换为 <?php,将每个 %> 替换为 ?>。如果您正在使用 short_tags,您可以将 <%%>,<%= 替换为 <??><?=,分别。