PHP: Declaring functions

This entry is part 30 of 54 in the series PHP Tutorial

Function names follow the same rules as variable names:

  • they must begin with a letter or an underscore, and
  • the rest of the characters in the name can be letters, numbers, or underscores.

The 2 functions below will generate the page header html and the page footer html.


function page_header()
    print '<html><head><title>Welcome to my site</title></head>';
    print "<body bgcolor='#ffffff'>";

$user = 'Daryl';
print "Welcome, $user";

function page_footer()
    print '<hr>Thanks for visiting.';
    print '</body></html>';

Series Navigation<< PHP: Functions
PHP: Passing arguments to functions >>