<?php /** * PHP7 Type Hinting Example. * * @copyright 2016 SqueezyWeb * @author Mattia Migliorini <mattia@squeezyweb.com> */ /** * String Type Hinting. */ function setValue(string $value) { var_dump($value); } // Call setValue() passing a string. setValue('foo'); // Output: // string(3) "foo" // Call setValue() passing an array. setValue([]); // Result: // PHP Warning: Uncaught TypeError: Argument 1 passed to setValue() must be of the type string, array given