π PHP Functions
Functions are reusable blocks of code you can call anytime in your PHP scripts. They help you organize, repeat, and manage your code.
π Example: Simple Function
Output will appear here...
π Key Function Rules
- Functions are defined with the
function
keyword.
- Function names should start with a letter or underscore (no numbers first).
- You can pass data into functions using parameters inside parentheses
()
.
- Functions can
echo
output or return
values back to where theyβre called.
- Call a function by writing its name followed by
()
.
π‘ Tip: You can define functions at the top of your PHP file and call them anywhere below β keeps your code neat and DRY (Don't Repeat Yourself).