【问题标题】:PHP 4 Compliance CheckerPHP 4 合规性检查器
【发布时间】:2011-03-10 10:24:11
【问题描述】:

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

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

【问题讨论】:

标签: php wordpress php4


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-04
      • 2018-12-10
      • 2013-08-02
      • 1970-01-01
      • 2010-12-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多