Scalar Types

Scalar types refer to the basic data types that hold a single value.

PHP scalar types include the following:

Integer int: integers are whole numbers without decimal points.

Float float: floats, also known as floating-point numbers or doubles, represent decimal numbers.

String string: strings are sequences of characters enclosed in quotes, single or double.

Boolean bool: booleans have two possible values: true or false.

Note that null is not considered a scalar type, and often behaves differently.

<?php
function gen_one_to_three() {
    for ($i = 1; $i <= 3; $i++) {
        // Note that $i is preserved between yields.
        yield $i;
    }
}

?>

Documentation

See also PHP 7 Scalar Type Declaration.

Related : Type System, Special Types, String, Boolean, Floating Point Numbers, integer, Alias Types, Constant Scalar Expression, Literal Types, Primitive Obsession, Relative Types

Added in PHP 7.0