
What is function in PHP?
PHP provides us many built-in helper partners works that you can call anyplace inside your application OR browser. They make your work process advantageous for working with exhibits and articles, ways, strings, URLs and different sorts.


ex:-
<?php | |
//function without parameter | |
function function_name() //no parameters | |
{ | |
echo "Welcome to DevOpsSchool"; | |
} | |
function_name(); //no arguments | |
echo "<br>"; | |
name(); //You can call function anyplace | |
echo "<br>"; | |
echo "This is new line"; | |
function name() | |
{ | |
echo "This is function which call to name()"; | |
} | |
echo "<br>"; //This is break line | |
//function with parameter | |
function value($name, $name1) //This is parameters | |
{ | |
echo "$name to $name1"; | |
} | |
value("Welcome", "DevOpsSchool"); //This is arguments | |
?> |
Why use Function in PHP:-
- You can use Easy to Debug.
- It is Reusability
- It is no code repetition
- Easy to handle codes
Rules for PHP variables:-
- Function name starts only with a letter or underscore(_).
- Function name cannot start with a number if the start then shows an error.
- You can not use reserved keywords as :- else, if, for, each, etc.
- Function names are case-insensitive, thus it is usually good form to call functions it appear in their declaration.




I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND