shadowline
Matching/Replacing << Functions - Intro >> Functions - Arguments
A function is a block of commands or instructions. If you have a specific block of commands that you are going to be using over and over again, this may be a very useful tidbit to use.

function function_name ( ) {
    some PHP commands;
    some PHP commands;
}

The word function lets the coding know that this set of commands will be executed when they are called upon by the following function name.

The function_name, like variable names, should be descriptive. Stay away from using spaces. Use_underscores_instead. The parentheses can be used to pass information into the function.

The commands in the function are normal PHP commands. There can be one or many. As usual, they all end with a semi-colon.

Calling a function is simply done by using it's function name as a command. Most functions are stored at the start of the page coding so they can be found and edited easily.

Somewhere near the top of the page coding :
<?php
function printit( ){
echo "This will print second.<br>";
}
?>

Later in the page coding :
<?php
echo "This will print first.<br>";
printit( );
echo "This will print third.";
?>

Result :
This will print first.
This will print second.
This will print third.
Matching/Replacing << Functions - Intro >> Functions - Arguments
shadow

Advertise in the banner along the top, Click here!

Valid XHTML 1.0 Transitional Valid CSS! Text Link Ads
shadow
shadow