- Joined
- Nov 6, 2007
- Messages
- 880
- Reaction score
- 11
This is how you make a functionA function is just a name we give to a block of code that can be executed whenever we need it. This might not seem like that big of an idea, but believe me, when you understand and use functions you will be able to save a ton of time and write code that is much more readable!
Open up notepad, or what ever you use to write your php,
PHP:
<?php
function hello() {
echo "hello world";
}
hello();
?>
Ok now lets say we wanted it to hello to what ever name we type in
PHP:
<?php
function hello($name) {
echo "hello $name";
}
hello("nameyouwanttoputin");
?>
You could do as many variables as you like,
PHP:
<?php
function hello($name, $lastname) {
echo "hello $name $lastname";
}
hello("HotelUnder", "Seige");
?>
Last edited:


