I wanted to try out PHP 7 return type declarations (for this I use PHP 7RC3 for windows).
wanted to start with something very simple:
function getme() : integer { return 434; } echo getme();
but this gives me a fatal error:
Fatal error: Uncaught TypeError: getme () return value must be an integer instance, integer return
then I also tried to display the return value, but return (integer) 434; or return (int) 434; gives me the same error;
Finally, I also tried:
function getme() : integer { $i = 434; return (integer) $i; } echo getme();
with the same result.
what am I doing wrong?
or what did I misunderstand here?
Thanks for any explanation and help!
UPDATE
this is why I thought I needed to use integer instead of int (special attention to Toby Allen):
from https://wiki.php.net/rfc/return_types :
Examples of misuse (...)
// Int is not a valid type declaration function answer(): int { return 42; } answer();
php php-7 return-type
low_rents
source share