Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 12:39:10
Original
1190 people have browsed it

再用用程序时,一般需要对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;
?> 

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!