String to integer

Converting strings to integer is needed on many code blocks, we have used two approaches for this :
1) normally typecasting string variable with (int) prefix.
2) intval function is used to do the same task

Example

<!DOCTYPE HTML>
<html>
	<head>
		<title>String to integer</title>
	</head>
<body>
	<?php
	$variable1 = "1234";

    $variable2 = (int) $variable1; // typecasting to integer
    
    echo $variable2 . "<br>";
    echo $variable2 + 3 . "<br>";
    
    // OR WE CAN ALSO USE INTVAL WHICH IS USED TO 
    // GET THE INTEGER VALUE OF A VARIABLE
    $variable3 = intval($variable1);
    
    echo $variable3 . "<br>";
    echo $variable3 + 3;

	?>
</body>
</html>

Output

1234
1237
1234
1237