简体   繁体   English

迁移到较新版本的PHP

[英]Migrating to a newer version of PHP

I notice that a couple of weeks ago PHP 5.3 reached release candidate stage (woo!), but then seeing the list of already-deprecated functions finally being removed, that got me thinking about whether it would break any of my old code. 我注意到几周前PHP 5.3已经达到了候选发布阶段(喔!),但随后看到已经被弃用的函数列表最终被删除,这让我想到它是否会破坏我的任何旧代码。

Short of doing a suck-it-and-see test (installing on a test server and trying it out), are there any sort of migration tools which can analyse your code to highlight issues? 没有做一个看不见的测试(在测试服务器上安装并试用它),是否有任何类型的迁移工具可以分析您的代码以突出问题? For example, if some scripts use the ereg_* functions. 例如,如果某些脚本使用ereg_*函数。

One technique you could use is to take the list of deprecated functions that is being removed and grep for them. 您可以使用的一种技术是获取正在删除的已弃用函数列表,并为它们添加grep。 A little shell scripting fu goes a long way for things like this. 对于像这样的事情,一个小的shell脚本fu很长的路要走。

Let's suppose you have a file deprecated.txt with deprecated function names one per line: 假设您有一个deprecated.txt文件,每行使用一个不推荐使用的函数名称:

for func in `cat deprecated.txt`
do
  grep -R $func /path/to/src
done

That will tell you all the instances of the deprecated functions you're using. 这将告诉您正在使用的已弃用函数的所有实例。

Nothing beats installing on a test server and running your unit tests. 没有什么比在测试服务器上安装和运行单元测试更好的了。 You do have unit tests, right? 你有单元测试,对吧? ;) ;)

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

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