Casting in Drupal

author details
AdiPie
12th Jan 2021
1 min read
Image
Casting in Drupal

Casting is the space that is found in between the (type) like int, array, etc, and variable in the code. In the PHP document, casting variables appear to always use a space to simplify and reduce mistakes inside the code.

Below are some of the samples:

(int) $myvariable: space in between the int and $myvariable is casting.

$bool_false = false;

$int_val = (int) $bool_false;

$boo_true = true;

var_dump((string) $boo_true); // Output will be "1"