WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML


 

PHP 7 - Return Type Declarations


In this tutorial Php 7 new feature introduce return type declarations


Example-True Return Type

Example

<?php
   declare(strict_types = 0);
   function returnIntValue(int $value): int {
      return $value;
   }
   print(returnIntValue(6));
?>
Try it yourself »

Output will be: 6




Example-False Return Type

Example

<?php
   declare(strict_types = 1);
   function returnIntValue(int $value): int {
      return $value + 1.0;
   }
   print(returnIntValue(6));
?>