简体   繁体   English

RegExp修复php标签

[英]RegExp to fix php tags

I made a website using php. 我使用php建立了一个网站。 In some places I put these php tags <?php ?> in other places just those <? ?> 在某些地方,我将这些php标签<?php ?>放在了其他地方,而那些<? ?> <? ?> . <? ?>

After doing a server migration the latter tags do not work because of php version differences. 在进行服务器迁移后,由于php版本的差异,后一个标记不起作用。 The new server understands only these tags <?php ?> . 新服务器仅理解这些标记<?php ?>

Is there any easy regular expression that you can provide me to replace all <? some php code here ?> 您可以提供任何简单的正则表达式来替换所有<? some php code here ?> <? some php code here ?> to <?php some php code here ?> . <? some php code here ?><?php some php code here ?>

You have two possibilities here: 您有两种可能:

  1. Enable the short tags with short_open_tag=On in php.ini php.ini使用short_open_tag=On启用简短标签
  2. You could use a negative lookahead: <\\?(?!php) , these needs to be replaced with <?php , see a demo on regex101.com . 您可以使用否定的前瞻: <\\?(?!php) ,这些需要替换为<?php ,请参见regex101.com上的演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM