Type casting to integer

Type casting to integer

Type casting to integer can be done using
two way
(i) The name of the desired type is written in parentheses
(ii) Converting to integer using function intval()

1.The name of the desired type is written in parentheses

<?php
$int1 = 10;
$int2 = (int) 10;
// OR
$int2 = int(10);
?>

2. Converting to integer using function intval()

<?php

$ab = ‘123.44′;

echo intval($ab); // will output 123

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.