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.  



Latest posts

Implementing CRUD Operations ¶

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


<ol> <li><a href="

Creating Model

<ol> <li><a href="

Get Free Quote