gpt4 book ai didi

PHP_VERSION_ID 是 int 但未定义。 (PHP-FPM 5.4.4)

转载 作者:可可西里 更新时间:2023-11-01 00:05:48 25 4
gpt4 key购买 nike

<分区>

标题解释了它,但这是我尝试做的:

if (!defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50400) {
trigger_error('PHP version 5.4 or above is required to run this code. Please upgrade to continue...', E_USER_ERROR);
}

出于某种原因,这是正在发生的事情:

var_dump(PHP_VERSION_ID);          // returns int(50404)
var_dump(defined(PHP_VERSION_ID)); // returns bool(false)

根据 defined 上的 php.net 页面,您可以这样做:

<?php
// PHP_VERSION_ID is available as of PHP 5.2.7, if our
// version is lower than that, then emulate it
if (!defined('PHP_VERSION_ID')) {
$version = explode('.', PHP_VERSION);

define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
}

// PHP_VERSION_ID is defined as a number, where the higher the number
// is, the newer a PHP version is used. It's defined as used in the above
// expression:
//
// $version_id = $major_version * 10000 + $minor_version * 100 + $release_version;
//
// Now with PHP_VERSION_ID we can check for features this PHP version
// may have, this doesn't require to use version_compare() everytime
// you check if the current PHP version may not support a feature.
//
// For example, we may here define the PHP_VERSION_* constants thats
// not available in versions prior to 5.2.7

if (PHP_VERSION_ID < 50207) {
define('PHP_MAJOR_VERSION', $version[0]);
define('PHP_MINOR_VERSION', $version[1]);
define('PHP_RELEASE_VERSION', $version[2]);

// and so on, ...
}
?>

关于为什么这不起作用的任何想法?我在 Debian Wheezy 上运行 PHP-FPM 5.4.4。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com