Home > Article > Backend Development > Use string function to output integer PHP version number_PHP tutorial
When reusing the program, it is generally necessary to integer the PHP version number to determine the output.
$temp=explode(".",phpversion()); //Get the version number in the form of an array
$num=count($temp); Number of elements in the array
$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;
?>