PHP - Cast type from variable <p>I was asking myself if it's possible to cast a string to become another type defined before</p> <p>e.g.</p> <pre><code>$type = "int"; $foo = "5"; $bar = ($type) $foo; </code></pre> <p>and where $bar === 5</p>