floatval Function in PHP

What is floatval() in PHP?

Explanation

PHP floatval function is used to get a float value from the given input. It returns the float value on success and 0 on failure.

Syntax:


floatval (var_name)

Example :


<?php
echo floatval(28.00)."<br />";
echo floatval(28.50)."<br />";
echo floatval(-28.51)."<br />";
echo floatval('Hscripts')."<br />";
?>

Result :

28
28.5
-28.51
0

PHP Topics


Ask Questions

Ask Question