Tuesday, February 26, 2019

PHP - Hypertext Preprocessor

What is PHP?
1.PHP is a server-scripting language
2.PHP is also called as Hypertext Preprocessor
3.PHP is a open source scripting language- PHP Course in Chennai

Syntax:
  The Basic Syntax of PHP is
         <?php
           // php code;
         ?>

Comments in PHP:
1.//  -> Is a single-line comment
2.#   -> another single-line comment
3./*..*/ -> It is a multiple-lines comment

Note:
1.Php code are ended with semicolon(;)
2.Php is case-sensitive
3.Variables are mentioned with $” sign
4.Echo is used to print the statement

Variables:
 In PHP,the variables are classified into three different types:
1.Local
2.Global
3.Static

Global Variable:
Global Variable can be accessed the outside given function

Local Variable:
The Local variable can be accessed within the function.PHP Course in Chennai

Conditional Statements in PHP:
1.If
2.If...else
3.If...elseif...else
4.Switch

If Statement:
1.If Statements will check both the conditions in the program It only executed when the condition is True.

Syntax for If-Statement:
       If (condition) {
            //program codes;
   }

If..else Statement:
1.If...else statement will check both the condition 
2.If condition is true mean it will execute the condition or if the condition is false mean it will go to else statement.PHP Certification in Chennai

Syntax for If..else Statement:
           If (condition) {
           //program codes;
           } else {
           //program codes;
           }

If...elseif...else Statement:
The If...elseif...else  Statement is executed when two or more condition.

Syntax for If...elseif...else:
  If (condition) {
   //program codes;
  } elseif (condition) {
  //program codes;
 } else  {
 //program codes;
 }

Switch Statement:
   The Switch statement is executed when the condition want to many task or action.

Syntax:
    switch (n) {
case label1:
    //Program codes;
    break;
   case label2:
    //Program codes;
   break;
   case label3:
    //Program codes;
   break;
   ...
default:
    //Program codes;
}

Looping Statements in PHP:
1.While Loop
2.do..While Loop
3.For Loop

1.It will execute the code until the condition is true.

Syntax:
while (condition) {
Codes;
}

Do..while Loop:
1.The do..while loop will execute once after execution it will check the condition.

Syntax:
do {
   codes;
} while (condition);

For Loop:
1.It will execute the code no of times

Syntax:
  for (init counter; test counter; increment counter) {
       codes;
}

PHP Data Types:
The PHP Data types are classified into following types,they are:
1.String
2.Integer
3.Float
4.Boolean
5.Array
6.Object
7.NULL
8.Resource

PHP-String:
A String is a collection of character enclosed with double quotes.
Eg: “Hello World!”  (or) ‘Hello World’
PHP-Integer:
A Integer is a PHP data type and it ranges from  -2,147,483,648 to 2,147,483,647.
PHP-Float:
In PHP float are used to determine the variable in decimal number.

PHP-Boolean:
The boolean are used only to show the results in true or false state.

PHP-Array:
An Array stores numerous values in a single variable.

PHP-Object:
An object is a PHP data type which stores data and information on how to process that data.

PHP-Null:
The Null data type is holding the value of null when the variable has no value to assign, then preferably NULL is used.

PHP-Resource:
The PHP Course in Chennai resource type is not an actual data type. It is the storing of a reference to functions of PHP to external resources.



No comments:

Post a Comment