You are on page 1of 1

Using Your PHP Function

Now that you have completed coding your PHP function, it's time to put it through a test run. Below is a
simple PHP script. Let's do two things: add the function code to it and use the function twice.

PHP Code:
<?php
echo "Welcome to Tizag.com <br />";
echo "Well, thanks for stopping by! <br />";
echo "and remember... <br />";
?>

PHP Code with Function:


<?php
function myCompanyMotto(){
echo "We deliver quantity, not quality!<br />";
}
echo "Welcome to Tizag.com <br />";
myCompanyMotto();
echo "Well, thanks for stopping by! <br />";
echo "and remember... <br />";
myCompanyMotto();
?>

Display:
Welcome to Tizag.com
We deliver quantity, not quality!
Well, thanks for stopping by!
and remember...
We deliver quantity, not quality!

Although this was a simple example, it's important to understand that there is a lot going on and there are
a lot of areas to make errors. When you are creating a function, follow these simple guidelines:

• Always start your function with the keyword function


• Remember that your function's code must be between the "{" and the "}"
• When you are using your function, be sure you spell the function name correctly
• Don't give up!

You might also like