Files
developer-roadmap/roadmaps/php/content/functions@WiGv7vi7Mtw-YqPMcnnyw.md
Arik Chakma 274082fd77 feat: clean roadmap content and sync scripts (#10181)
* refactor: clean to roadmap content

* refactor: move shared helpers into scripts/lib
2026-07-28 05:45:17 +06:00

812 B

Functions

Functions in PHP are self-contained blocks of code that carry out specific tasks and can be reused throughout your application. A function is defined with the word "function" followed by a name, and it should return a value using the "return" statement. To use a function, you simply need to call it by its name. You can also pass parameters to functions to influence how they work. Here's a simple function:

function greet($name) {
    return "Hello, " . $name;
}

echo greet("John"); // Outputs: Hello, John

In the code above, "greet" is a function that takes one parameter "name". It concatenates "Hello, " with the name and returns the result.

Visit the following resources to learn more: