我正在使用 PHP 模板化我的 php.ini。我有一个脚本可以通过使用 CLI PHP 脚本从模板生成 httpd.conf、apachectl 和 php.ini 来设置开发环境。不幸的是有文字 <?
和 <?php
php.ini 中的字符串(在注释中)。是否有可能以某种方式转义那些以便 php 不会将它们解释为正常的 PHP 转义序列?
目前我的解决方法是将它们包装在一个真正的 PHP 转义序列中,将它们作为字符串输出,如下所示:
; This directive determines whether or not PHP will recognize code between
; <?php echo "<? and ?>" ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php echo "<?php and ?>" ?> tag combination. With the wide spread use
;
最佳答案
这个:
<?php echo "<?php"; ?>
将输出:
<?php
关于转义文字 <?php 和 <?在 PHP 脚本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1469105/