Skip to content
Advertisement

PHP return type

Is it possible to define the return type like this?

public static function bool Test($value)
{
      return $value; //this value will be bool
}

Advertisement

Answer

As per this page : http://php.net/manual/en/language.types.type-juggling.php

You can try doing,

return (boolean) $value;

Now PHP offer return type declaration from PHP 7. I have explained how to use return type in PHP

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement