Advertisement
Yousuf1791

type_hinting

Jun 18th, 2023
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.16 KB | None | 0 0
  1. <?php
  2.  
  3. class base{
  4.  
  5.     function sum(int $value){ //only integer value can be passed here
  6.         echo $value + 1;
  7.     }
  8.  
  9. }
  10.  
  11. $obj = new base();
  12.  
  13. $obj->sum("10");
  14.  
  15. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement