Joomla Web Solution | Website And Mobile Application Development Company In Ahmedabad At India



An array is a special variable, which can hold more than one value at a time.

Array Syntax: $arrayName = array ("value1","value2","value3");

In PHP, there are three types of arrays:

  • Indexed arrays or Numeric arrays - Arrays with numeric index
  • Associative arrays - Arrays with named keys
  • Multidimensional arrays - Arrays containing one or more arrays

1) array_shift Function:

The array_shift function removes the first element of an array from the array and stores it in the receiving variable.

$myarray = array("Apples", "Oranges", "Pears");
$fruit = array_shift($myarray);  
echo $fruit; // Apples
print_r($myarray);  // Oranges and Pears will be displayed without Apples

2) array_unshift Function:

Prepend one or more elements to the beginning of an array.

$queue = array("orange", "banana");
array_unshift($queue, "apple", "raspberry");

Traits is look like of class. it contain group of methods you want to use in another class.

Like abstract class we can't create object of traits but we can use it in another class.

So it's solve multiple inheritance problem in PHP.

It's lot of look like interface, but diffrent is in interface we can only define method/function but we can't implement but in traits we can do it.

Destructors are automatically called when object are destory.

Constructor are automatically called when object are created.

PHP introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final keyword.

Method in child class with same name, same parameter and same access as parent class is call method overloading.

Method with same name but diffrent parameter is called method overloading.

Single interface with multiple implementation is call polymorphism

How you visible private and protected method and variable out side class is called encapsulation.

- Interface same as abstract class, we can't create object of interface class but we implement interface class to another class.
- All methods declared in an interface must be public, this is the nature of an interface. To implement an interface, the implements operator is used.
- Interface class method are define only but it declare out side class where it implement.
- Interface support multiple inheritance