Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的应用程序至少需要 PHP 5.4。
当前代码仅检测到 5.0 或更高版本:
$phpv=phpversion(); $t=explode(".", $phpv); if($t[0]>=5) $ok=1; else $ok=0;
键入 5.4 或 54 而不是 5 无法正常工作。
使用爆炸的第二部分怎么样:
if($t[0]>=5 && $t[1]>=4) ...
希望这可以帮助。
使用version_compare:
version_compare
if (version_compare(PHP_VERSION, '5.4.0') < 0) { echo 'Minimum required version is 5.4.0. You have: ' . PHP_VERSION . "\n"; }