DWPD-2.4: Write a PHP script to set type of variable using type casting.

php type cast easy example
Lab # 2
Basics of PHP


4. Write a PHP script to set type of variable using type casting.

Lab-2-4-typecast.php

<?php
define("PI",3.14);
$r=5;
$ans=PI*$r*$r;
echo "Radius(in double)=$ans"."<br>";
settype($ans,"int");
echo "Radius(in integer)=$ans";
?>


Output

type cast in php output
Type Casting in php | by Practical Server


Happy Coding 🙂

Leave a comment