1. Home
  2. Computing & Technology
  3. PHP / MySQL

Function

By Angela Bradley, About.com

Definition: A function is like a subroutine. It is a predefined set of commands that are executed when the function is called. Functions can be as simple or complex as desired, and can contain other functions within themselves. In the case of PHP, some functions come preprogramed and others you can define on your own.
Examples:
<?
SQRT (9);
// this function is predefined in PHP and performs the mathematical computation of square root. In this case would output the number 3

function examplefunction () //defining a function
{
print "Hi, I am a Function";
}
examplefunction (); //calling a function
// this function simply prints Hi, I am a Function when called
?>

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Programing Glossary
  5. php function - function in php - php string function

©2009 About.com, a part of The New York Times Company.

All rights reserved.