PHP 4合规性检查器

时间:2011-03-10 10:24:12

标签: php wordpress php4

是否有工具可以检查您的代码并反馈任何PHP4合规性问题?我刚刚为WordPress开发了一个Widget,并没有使用任何PHP5.3功能,但使用了PHP5功能。

我没有意识到WordPress PHP版本要求如此之低(PHP4.3),现在我正在考虑“减少”代码以使其普遍兼容的任务。

2 个答案:

答案 0 :(得分:3)

您使用PEAR包PHP_CompatInfo检查您的代码。引用:

  

PHP_CompatInfo将解析文件/文件夹/脚本/数组以找出最小值   它运行所需的版本和扩展。具有高级调试输出   它显示哪些功能需要哪个版本和CLI输出脚本

Basic Example:

require_once 'PHP/CompatInfo.php';
$source = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'math.php';
$info = new PHP_CompatInfo();
$info->parseFile($source);

另见User Guide for the PHP_CompatInfo

答案 1 :(得分:0)

使用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.