Explain Scalar type declarations in PHP7.


Posted On: Feb 22, 2018


Scalar type declarations is the new feature in PHP7 that has added new declaration types such as int, string, Boolean, float. This declaration has two options-

  • Coercive– this is a default mode in scalar type declarations, which need not be specified.
  • Strict– it has to be explicitly hinted.

Scalar declarations have attracted a lot of controversy regarding its implementation. These are the statements that accept the arguments (parameters) and returns the values of the given scalar data type which can be int, float, string, etc. To stimulate this function, the name of the scalar data type should be added before the parameter.

FUNCTION: FunctionName (int $a, int $b)
{return $a +$b; }

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    PHP 7 interview questions

    What new features PHP7 has in store for us?

    What new features PHP7 has in store for us?..