Blog Details

PHP Function



                                

* PHP Function :-

  • A function is a block of statements that can be used repeatedly in a program.
  • A function will not execute immediately when a page loads.
  • A function will be executed by a call to the function.
 

Syntax :-

  function functionName() { code to be executed; }

Example :-

  ?php function writeMsg() { echo "Hello world!"; } writeMsg(); // call the function ?>

* PHP Function Arguments :-

  • Information can be passed to functions through arguments. An argument is just like a variable.
  • Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just seperate them with a comma.
 

Example :-

  <?php function familyName($fname) { echo "$fname Refsnes.<br>"; } familyName("Jani"); familyName("Hege"); familyName("Stale"); familyName("Kai Jim"); familyName("Borge"); ?>

 Output Result :-

  Jani Refsnes. Hege Refsnes. Stale Refsnes. Kai Jim Refsnes. Borge Refsnes.  


Categories

Core_PHP

Latest posts

13.05.14
Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t

13.05.14
View

<ol> <li><a href="http://www.yiiframework.com/do

13.05.14
Creating Model

<ol> <li><a href="http://www.yiiframework.com/do

Get Free Quote