Ajax Tutorials, PHP Tutorials, Javascript Tutorials, Visual Basic.Net Training, XHTML tutorials, php script library, PHP Codes, Programming tutorials, web development tutorials
Web Development Tutorials, Programming Tutorials, PHP Script Index
Home | Forums | Downloads | Books | Submit Content | Links

Programming Articles

  PHP articles
  MySql articles
  Visual Basic.Net articles
  Java articles
  ASP articles
  ASP.Net articles
  Visual Basic articles
  CSS articles

Programming Tutorials

  PHP tutorials
  MySql tutorials
  Visual Basic.Net tutorials
  Java tutorials
  ASP tutorials
  ASP.Net tutorials
  Visual Basic tutorials
  HTML tutorials
  CSS tutorials

Programming Source Codes

  PHP scripts
  Visual Basic.Net scripts
  JavaScript scripts
  ASP scripts
  ASP.Net scripts
  Visual Basic scripts

Our Partners

  Free Resources
  Publisherbank
  Free Link Directory
  PHP Magazine
  Webmaster Passion
  Search Engine Bank
  Free Directory Site
  Free PHP Scripts
  Links Shopping Mart
  Variety Bazar
  Urdu Office Tutorials
  Evernew Scripts
  Evernew Scripts
  Evernew Directory
  Our Achievements
  Web templates
  Buy and Sell Templates
  Text Link Traders
  Directory Metro
  Gifts Choice
  Valentines Ecards
  Template Directory

Function in PHP

Date:2006-03-19

A function is a set of code that can optionally accept parameters and return a value. A PHP function may take zero or more parameters.

A function has three major parts:

  • The name of the function
  • Parentheses include Arguments, but Arguments are optional, An An argument is simply a value (or a reference to a value) that the function is expecting. A function might expect zero, one, two, three, or more arguments.
  • Body of the function between curly brackets (opening and closing)

Every function is stated with function keyword. The syntax of PHP function is as follows:

function function_name (optional $arg1, $arg2) {
block of code
}

The parameters of function are optional. you can use function without paramters. For example:

function topwebsite() {
print "http://www.programmersbank.com";
}

topwebsite();

Output:

http://www.programmersbank.com

Another example of PHP with argument is:

function topwebsite($website) {
print $website;
}

In this examples you have used one argument $website.

topwebsite("http://www.programmersbank.com");

See another function:

function valueExpressions($value1,$value2,$symbol) {
$symbol;
$result=$value1."".$symbol."".$value2;
}

This function valueExpressions has three arguments $value1, $value2, $symbol. The user will call this function as follows:

valueExpressions(70,65,'+');

See this called function, you understand, 70 is this value against $value1 argument,

Note: A function is a block of code that is not immediately executed but can be called by your scripts when needed.



Desclaimer | Privacy Policy | Submit Content | Links | Link to Us | Sitemap |Contact Us
Copyright Programming Tutorials, Web Development Tutorials, Source codes © All Rights are Reserved.
Powered By Evernew Solutions

Personal Loan - Loans - Phoenix Landscaping - Credit Card Consolidation