1.2.117. Cast Usage

List of all cast usage.

PHP does not require (or support) explicit type definition in variable declaration; a variable’s type is determined by the context in which the variable is used. Until PHP 7.2, a (unset) operator was available. It had the same role as unset() as a function.

<?php

if (is_int($_GET['x'])) {
    $number = (int) $_GET['x'];
} else {
    error_display('a wrong value was provided for "x"');
}

?>

See also Type Juggling and unset.

1.2.117.1. Specs

Short name

Php/CastingUsage

Rulesets

All, Appinfo, CE, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

cast

Available in

Entreprise Edition, Community Edition, Exakat Cloud