Saturday, June 10, 2023

[php] Why Colon After PHP Function() ?

 .

it’s the new features.

.

In PHP, the : symbol is used to indicate the start of a block of code that defines a specific type of construct, such as a function, a class, or a control structure (like if, for, while, etc.).

.

In PHP 7 and later, you can specify the return type of a function or method by adding a colon followed by the type name after the argument list.

.

For example, the above code defines a function multiply that takes two integer arguments followed by a colon and a keyword integer which means the function is expected to return an integer.

No comments:

Post a Comment