简体   繁体   English

代替

[英]replace <? with <?php all files phpstorm, cl, etc

I have a project I am moving that has many files, many of which were opened with <?我有一个正在移动的项目,其中包含许多文件,其中许多文件是用<? rather than <?php而不是<?php

I'm trying to globally replace <?我正在尝试全局替换<? with <?php in text wrangler, sublime text, and phpstorm, but none seem to want to grab just the <?在 text wrangler、sublime text 和 phpstorm 中使用<?php ,但似乎没有人想只获取<? (using the whole word check box). (使用整个单词复选框)。

I'll take any approach, but i do like the GUI for this one so I can inspect the search/replace results.我会采取任何方法,但我确实喜欢这个的 GUI,所以我可以检查搜索/替换结果。

As an FYI, I am migrating a codebase.作为一个仅供参考,我正在迁移一个代码库。 On the new server I am getting a raw dump of the php file for files opened with <?在新服务器上,我得到了用<? . . stupid.愚蠢的。 Replacing with <?php fixes the issue.替换为<?php可以解决问题。 There are probably other ways to fix the issue.可能还有其他方法可以解决此问题。

The easiest way for me to solve this was simply to enable short tags, as described here...我解决这个问题的最简单方法就是启用短标签,如此处所述...

How to enable PHP short tags? 如何启用 PHP 短标签?

Put the following line in your PHP.ini:将以下行放入您的 PHP.ini:

short_open_tag=On

This one is quite simple, as it is easy.这个很简单,因为它很容易。 I am assuming that your text editor supports Find/Find & Replace.我假设您的文本编辑器支持查找/查找和替换。 If it doesn't go download and install Notepad ++ and hold CTRL + F and that'll bring up the find menu.如果它不去下载并安装 Notepad ++ 并按住 CTRL + F ,那将调出查找菜单。 After that, open all of the relevant PHP files.之后,打开所有相关的 PHP 文件。 Navigate to the find & replace tab in the CTRL menu.导航到 CTRL 菜单中的查找和替换选项卡。 From there enter <?从那里输入<? and <?php into the two boxes, check all documents and hit replace all.<?php放入两个框中,检查所有文档并点击全部替换。

I have the same problem but I would like all scripts to have <?php instead of allowing <?我有同样的问题,但我希望所有脚本都有<?php而不是允许<? modifying the php.ini修改 php.ini

I use visual studio code but it works for any editor (sublime, etc.).我使用 Visual Studio 代码,但它适用于任何编辑器(崇高等)。 First I make a change in the files and replace <?首先,我对文件进行更改并替换<? by <?php At that time I will have the ones that had <? by <?php到时候我会有那些有<? correct and I will have the ones with <?php as <?phpphp正确,我将使用<?php作为<?phpphp

The next thing is to replace <?phpphp with <?php and that's it.接下来是用<?php替换<?phpphp就可以了。

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

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