php declare 28strict types 3d1 29

Solutions on MaxInterview for php declare 28strict types 3d1 29 by the best coders in the world

showing results for - "php declare 28strict types 3d1 29"
Leo
06 Jan 2021
1"Strict types" mode only checks types at specific points in the code; it does not track everything that happens to the variable.
2
3Specifically, it checks:
4
5the parameters given to the function, if type hints are included in the signature; here you are giving two ints to a function expecting two ints, so there is no error
6the return value of the function, if a return type hint is included in the signature; here you have no type hint, but if you had a hint of : int, there would still be no error, because the result of $a + $b + $c is indeed an int.
7Here are some examples that do give errors:
8
9declare(strict_types=1);
10$a = '1';
11$b = '2';
12function FunctionName(int $a, int $b)
13{
14    return $a + $b;
15}
16echo FunctionName($a, $b);
Lennart
15 Mar 2018
1declare(strict_types = 1);