Type Hinting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kiskiller0
    New Member
    • Jun 2018
    • 2

    Type Hinting

    Type Hinting Cannot be used to require a parameter to be of a particular scalar type (such as integer or string or to have a particular trait.
    _Programming Php_
    code:

    <?php
    function yeld(int $a){
    print $a;
    }
    random(5);
    random("hey");
    ?>

    output:
    5
    Fatal error: Uncaught TypeError: Argument 1 passed to random() must be of the type integer, string given, called
Working...