Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mindy6's avatar

Can someone clarify for me real quick on what a function declaration is?

So this is something that has been confusing me for a bit. After learning about hoisting and variable environments, I’m even more confused https://mobdro.bio/ .

Is a function declaration just: function functionName() {}

Or is it: function functionName() { code block }

??

From my understanding, it is the former, because isn’t the code block the function definition? But I want to be completely sure.

0 likes
2 replies
Nakov's avatar

you got it right:

A function consist of two parts:

Declaration: the function's name, return type, and parameters (if any)

Definition: the body of the function (code to be executed)

Please or to participate in this conversation.