computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
796 B
13 lines
796 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: |
|
|
|
```php |
|
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. For more on PHP functions, visit the PHP documentation at [php.net](https://www.php.net/manual/en/language.functions.php). |