About us Privacy Disclaimer Contact us
FAQ Help Advertising Feedback
Home Sitemap Search Donate us

  Home > Computer & I'net > Functions - Intro...

   Browse by title articles:
   What is hot:

Character Classes

Matching/Replacing

Functions - Intro

Functions - Arguments

Functions - Return Values

Include

Frames - Good or bad?
Your Website and your Brand
Steps To Optimizing Your HTML Codes
Graphics for the web: JPG and PNG Files
Prev articles123456789 10 1112Next articles



Functions - Intro


Computer & I'net articlesFunctions - Intro

by David Stanley    



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.



-----------------
Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission.





Cost Spreading




  Disclaimer | Privacy | Terms of useCopyright © 2004 Nice2know.com