Простые типы / Строки

<?php

//to int
$strNumber = "42";
//the first method
$number1 = (int)$strNumber;
//the second method
$number2 = $strNumber + 0;
echo $number1, "\n", $number2, "\n";

//to Double and Float
//the first method
$strPi = "3.14";
$pi = (float)$strPi;
//the second method
$strExp = "2.71828";
$exp = $strExp + 0;
//the third method
$strHalf = "0,5";
$strHalf = str_replace(',''.', $strHalf);
$half = (float)$strHalf;
echo $pi, "\n", $exp, "\n", $half, "\n";