是否有工具可以检查您的代码,并可以反馈任何PHP4遵从性问题?我刚刚为WordPress开发了一个小部件,没有使用任何PHP5.3特性,但使用了PHP5特性。
我没有意识到PHP的版本要求如此之低(PHP4.3),现在我正在考虑“简化”代码以使其通用兼容的任务。
发布于 2011-03-10 18:46:33
您可以使用PEAR包PHP_CompatInfo检查代码。引用:
PHP_CompatInfo将解析文件/文件夹/脚本/数组,以找出运行它所需的最低版本和扩展名。具有高级调试输出,可显示哪些函数需要哪个版本以及CLI输出脚本
require_once 'PHP/CompatInfo.php';
$source = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'math.php';
$info = new PHP_CompatInfo();
$info->parseFile($source);发布于 2011-03-10 18:39:27
使用php 4函数没有问题,首先使用phpinfo()检查服务器的php版本,如果是PHP 5.x,则检查是否正在使用以下任何函数
请参阅下面给出的弃用函数
不推荐使用的函数:
- call_user_method() (use call_user_func() instead)
- call_user_method_array() (use call_user_func_array() instead)
- define_syslog_variables()
- dl()
- ereg() (use preg_match() instead)
- ereg_replace() (use preg_replace() instead)
- eregi() (use preg_match() with the 'i' modifier instead)
- eregi_replace() (use preg_replace() with the 'i' modifier instead)
- set_magic_quotes_runtime() and its alias, magic_quotes_runtime()
- session_register() (use the $_SESSION superglobal instead)
- session_unregister() (use the $_SESSION superglobal instead)
- session_is_registered() (use the $_SESSION superglobal instead)
- set_socket_blocking() (use stream_set_blocking() instead)
- split() (use preg_split() instead)
- spliti() (use preg_split() with the 'i' modifier instead)
- sql_regcase()
- mysql_db_query() (use mysql_select_db() and mysql_query() instead)
- mysql_escape_string() (use mysql_real_escape_string() instead)
- Passing locale category names as strings is now deprecated. Use the LC_* family of constants instead.
The is_dst parameter to mktime(). Use the new timezone handling functions instead.https://stackoverflow.com/questions/5258308
复制相似问题