Testing: PHP declare(strict_types=1);

Step: #2

Demos to clarify certain myths:
I get the general impression that many programmers are afraid of adding "declare(strict_types=1);" to their PHP files? These demos are to clarify the implications of adding the current sharpest tool to one's toolbox.


All tests have the following set in this "parent" PHP file:
  1. declare(strict_types=1);
  2. ini_set('display_errors', 'true');
  3. error_reporting(-1);
  • item #1 - file-specific and does not affect include files.
  • item #2 & 3 - affects this file and all included files.
Special Note:
CI4 uses the same settings when in 'development' mode.


Most demos call the following:

function fnTest($var) {...}
Results for each test:
  • The included source file is shown.
  • Comments sometimes shown to highlight specific points.
Click the "Next" button above to start the demos.



Wonderful place for a footer