
Java
<?php
$foo = "A string";
$foo = 1;
$foo = array();
?>
You can however explicitly cast variables to a certain type:
<?php
$int = (int)4.5/2;
?>
In contrast, strongly typed languages such as C/C++/Java force you to declare the type of value a variable will hold and explicitly state the new type to perform a conversion; not doing so will result in a compiler error.
Copyright © 2026 eLLeNow.com All Rights Reserved.