Friday 27 April 2018

PHP Functions- PHP Training in Chandigarh

PHP Functions

PHP Built-in Functions
               
A function is a self-accommodate block of code that hang a specific task.
PHP has a huge collection of internal or built-in functions that you can call directly within your PHP scripts to perform a specific task, like gettype(), print_r(), var_dump, etc.Get more knowledge about PHP functions with
 PHP Training in Chandigarh



PHP Training in Chandigarh

PHP User-Defined Functions


In addition to the built-in functions, PHP also grants you to explain your own functions. It is a way to create reusable code bottle that execute particular tasks and can be stored and continue independently from main program. Here are some improvements of using functions:

Functions reduces the recurrence of code within a program — Function allows you to extract commonly used block of code into a single basic. Now you can functions the same task by calling this perform anywhere you want in period your writing without acquire to copy and paste the same block of code again and again.

Functions makes the code much simpler to continue — Since a function created once can be used many times, so any adjustment made central a function naturally achieve at all the apartments without stunning the definite files.
Functions makes it easier to eliminate the errors — When the program is subdivided into functions, if any error occur you know absolutely what function create the glitch and where to find it. Therefore, adapting fault becomes much easier.

Functions can be restate in different application — Because a function is detached from the rest of the writing, it's simple to restate the same behavior in other function just by including the php file containing those functions.

The following section will show you how easily you can define your own function in PHP. For learning practically  go for PHP Training in Chandigarh.

Passing Arguments to a Function by Reference

               
In PHP there are two action you can gap arguments to a function: by value and by reference. By default, function arguments are passed by value so that if the value of the argument within the function is changed, it does not get affected outside of the function. However, to allow a function to modify its arguments, they must be moved by reference.
Passing an argument by reference is done by pretend an ampersand (&) to the exchange name in the function definition, as shown in the example below:

<?php
/* Defining a function that multiply a number
by itself and return the new value */
function selfMultiply(&$number){
   $number *= $number;
   return $number;
}
$mynum = 5;
echo $mynum; // Outputs: 5
selfMultiply($mynum);
echo $mynum; // Outputs: 25
?>

Understanding the Variable Scope
               
However, you can declare the variables anywhere in a PHP script. But, the location of the declaration determines the extent of a variable's visibility within the PHP program i.e. where the variable can be used or accessed. This accessibility is known as variable scope.
               
By default, variables declared within a function are local and they cannot be viewed or manipulated from outside of that function, as demonstrated in the example below:

<?php
// Defining function
function test(){
   $greet = "Hello World!";
   echo $greet;
}
test(); // Outputs: Hello World!
echo $greet; // Generate undefined variable error
?>

PHP Training in Chandigarh is the best place for learning PHP Functions ,variables framework ,content management and other by Cbitss Technologies.

Wednesday 18 April 2018

PHP Object Oriented Programming Concepts

PHP Object Oriented Programming Concepts

Class vs Object

Class is like your house blueprint. Before your house is build up there is a house blueprint. It is 
not an certain house, but a plan how this house will look like, how many rooms it will have and 
so on. Then the house will be build up by giving the blueprint. The blueprint is a class and your
 actual home is an object. Learn  OOPs concepts in Detail with PHP Training in Chandigarh.
A few key points to keep in mind:
  • Class is universal, whereas Object is defined
  • Class defines properties/functions of an Object
  • Object is an instance of a Class
  • You can instantiate an object, but not a Class
PHP Training in Chandigarh

 PHP Class

Class is contains all the properties and methods. In this simple class. $postCode is a equity 
and ringBell() is a method. They are all prefixed with a clarity keyword (public).
Class House {

    public $postCode = “560121”;

    public function ringBell() {
        echo “Ding Dang Dong”;
    }
}
                  

Visibility

Every method and property has its own visibility. Here we have  three types of visibility in PHP. 
They are announced by keywords public, protected and private. Each one of them authority how 
a method or property can be approach by outsiders.
Public: It allows everyone from outside access its method. This is the default visibility in PHP 
class when no keywords are added to a method.
Protected: It only allows itself or children classes to approach its method.
Private: It does not allow anyone except itself to approach its method.

Inheritance in PHP

It lets subclass inherits essincial of the parent class. Parent class choose what and how these
 methods to be inherited by declared visibility.

Polymorphism in PHP

The arrangement of a single interface to attributes of different types.  PHP is adept to actions
 objects moderation depending on data type or class. This powerful feature allows you to write
 interchangeable objects that sharing the same interface.

Encapsulation in PHP
Encapsulation is used to hide the values or state of a analytic data object center a class, 
avoid unauthorized parties direct access to them. It is  approach that motivates us to think 
through a method/class authority and hide its internal implementation all the details accordingly. 
This will make it easy to modify the internal code in a long run without touching other part of the 
system. Visibility is the mechanism for encapsulation.

Abstraction in PHP

Abstraction is the approach that focus on the particulars and detailed application of things, to the
 types of things,the operations available ,etc, thus making the programming simple, more basic, 
and more abstract. It is like a archive instead of a condition.

Interface vs Abstract class in PHP

Interface

Interface declares what methods a class must have without having to implement them. Any class 
that appliance the alliance will have to implement particulars of those declared methods. Interface 
is not a class, so you cannot instruct an interface.
Abstract class
Abstract class is able to enforce subclasses to implement methods similar to interface.
 When a method is declared as abstract in an abstract class, its derived classes must 
implement that method.Get more Knowledge about OOP’s Concepts 
 with PHP Training in Chandigarh.

For Infographic Visit:- https://goo.gl/oKFxbt