PHP: Passing arguments to functions

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

The input values supplied to a function are called arguments.

We can modify page_header( ) to take an argument that holds the page color.


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

$color = '#E3DCDC';
$user = 'Daryl';
print "Welcome, $user";

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


Series Navigation<< PHP: Declaring functions
PHP: Built-in functions >>
Posted in