Is it possible to write strictly typed PHP code?

In PHP 7 are implemented “Scalar Type Declarations”, e.g.:

public function getBalance(): int {
    return 555;
}

You need to declare, that you will use strict types:

<?php
    declare(strict_types=1);

    function sum(int $a, int $b): int {
        return $a + $b;
    }

    sum(1, 2);
?>

More information: https://wiki.php.net/rfc/scalar_type_hints_v5

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)