PHP 7 Return Type Declarations - PHP7

What is PHP 7 Return Type Declarations?

In PHP 7, a new characteristic, Return type declarations have been introduced. Return type declaration specifies the type of value that a meaning should return. Following types for return types can be affirmed.

  • int
  • float
  • bool
  • string
  • interfaces
  • array
  • callable

Example - Valid Return Type

It produces the following browser output –

Example - Invalid Return Type

It produces the following browser output –

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PHP7 Topics