Home  >  Article  >  php教程  >  使用字符串函数输出整数化的PHP版本号

使用字符串函数输出整数化的PHP版本号

WBOY
WBOYOriginal
2016-06-13 12:39:101109browse

再用用程序时,一般需要对php版本号整数化后进行判断,从而确定输出。

$temp=explode(".",phpversion()); //以数组形式获取版本号
$num=count($temp);               //计算数组中的元素数量
$phpver=0;
switch($num)
{
  cas 3:
     $phpver=$phpver+(intval($temp[2]));
  cas 2:
     $phpver=$phpver+(intval($temp[1]*10);
  cas 1:
     $phpver=$phpver+(intval($temp[0]*100);
  default:
}
echo $phpver;
?> 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn