Wednesday, 10 February 2016

Definitions and use of function

Definitions and use of function.

A function is a group of code which takes one or more parameter/arguments, and after process, give return a value. A function will not execute until we call to the function.

Note: A function name can not a number.

Syntax:

function YourFunctionName( )
{  
    STATEMENTS 1;
    STATEMENTS 2;
    STATEMENTS 3;

}

What is Arguments?

An argument is a variable, which is passed in functions. You can pass many parameter ( or argument) in a function (separate with a comma).

Example: 

function  NameAge ( $name, $age ) 
{
    echo "$name age = $age";
}
in this example, only pass two parameter, like this you also pass more parameter according your request.

What is Default Argument in a function?

If you call the function without argument value, then it takes the default value as this argument.
Example: 

<?php
function  NameAge ( $name, $age=20 ) 
{
    echo "$name age = $age";
}

NameAge ("Rakesh");           // output:  Rakesh age = 20
NameAge ("Rakesh","28");  // output:  Rakesh age = 28

?>

In this Example, $age=20 is  default argument  if we not pass any age, then its take $age=20.

Different  types of functions in PHP.


  1. User defined function
  2. Return value function
  3. Variable function
  4. Anonymous function

User defined function

Normally, all kinds of useful functions built-in PHP library. But if a function not find in PHP library. Then PHP allows you to build your own functions.

Tip:"Give the function a name that reflects  the function work"

<?php
  function myFirstFunction()
 {
    echo "This is My Function";
  }
?>

Return value function 


Return value function, return a value according to argument, with return statement.

<?php
  function addTwoNo($a, $b) {
    $total = $a + $b;
    return $total;
  }
 echo $sum = example(20, 30);
?>

Variable function

PHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth.

<?php
    $func = "sqrt";
    print $func(7);
?>

Hear we see that PHP are calling a function using a variable, 

Anonymous function

An anonymous function is simply a function with No Name.
An anonymous function has no name so you would define it like this:
<?php
function () {
  return "Hello PHP";
}
?>

Saturday, 6 February 2016

How cursor move in "For Loop"?

How cursor move in "For Loop"?


For Loop execute specific Line/area  again and again, until the certain condition not false.

 The syntax of a for loop is:

 for(initialization; condition; increment/decrement)

for(i=0; i<=10; i++)
{
    Print i;
}


Step by Step For Loop Process


1. Cursor initialize the value i=1;
2. then check the condition (if i<=10) 
3. if condition is true (means i<=10) then , cursor execute next line.
4. after that go to  increment/decrement,
5. in step five, again check condition (if i<=10), means again step 2 until condition (if i<=10) not flase.
6. if condition (if i<=10) flase, cursor jump out the loop.



Flowchart of for loop


Saturday, 30 January 2016

How to Install WAMP Server? Step by Step Process.

How to Install WAMP Server? Step by Step Process.


  1.  Search on Google "Download wamp Server".
  2.  Click on http://www.wampserver.com/en/
  3.  Select version according to your computer specification.
  4.  After download the WAMP Double Click on setup.
  5. After Start dialog box, You have only follow easy step to Install , only click NEXT,NEXT,NEXT,YES,NEXT and FINISH.















PHP is a programming language.

PHP is a programming language.


The PHP means Hypertext Preprocessor (PHP) is a scripting language,  where we develop  dynamic website  interacts with databases.PHP is free and it Download from www.php.net
PHP is a server side programming  language. Therefore, you need a server to run PHP.
  1. LAMP :-(Linux Apache MySQL PHP);
  2. WAMP :-(Windows Apache MySQL PHP);
  3. MAMP :-(MAC Apache MySQL PHP);
  4. XAMPP:-(x-os Apache MySQL PHP Perl); 
For develop and run PHP need  three components to be installed in your computer.
  1. Linux or windows server (Ex:-WAMP)
  2. Code editor  (Ex:-notepad++)
  3. web browser (Ex:- mozilla firefox)