2011-03-10 15 views
0

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

我没有意识到WordPress的PHP版本要求太低(PHP4.3),现在我正在考虑让代码变得“瘫痪”以使其通用兼容。

+2

只是向我们展示的代码 – seriousdev 2011-03-10 10:30:56

+0

尝试使用'的var_dump(!function_exists (“函数名称”))' – diEcho 2011-03-10 10:41:21

+0

[确定最低要求的PHP版本]可能的重复(http://stackoverflow.com/questions/1924565/determine-minimum-required-php-version) – Gordon 2011-03-10 10:48:54

回答

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