Advance PHP

In core PHP we learn only the basic elements but in advanced PHP we are learning many other elements or their uses in real-life projects that is why it is called advanced PHP. Remember that there is no difference between core PHP and advanced PHP.

why we should learn advanced php?

The good feature of PHP is that it is very robust and scalable. PHP is much the same as if it was an object-oriented language, making it a very easy language to deal with. PHP also has a very strong meta-language for programmers. PHP has increased demand for language development year over year.

Class & Object

Class:-

  • PHP class is a group of values and a set of operations to manipulate the value or to change the value.
  • Classes are the blueprints of objects.
  • Classes are nothing without objects.
  • Class is a programmer-defined data type.
  • The syntax for defining a class in PHP is very simple.
  • We use the keyword class followed by the name of the class.

Rules for creating class:-

  • Class name can be any valid label like(Vikash,Ram,Boss,Cat,Plant e.t.c).
  • Cannot be used Php reserved words.
  • The class name, should start with letter or underscore.
  • for remembering class, the class name starts with the first capital letter.

syntax:-

class Classname
{
var&variable_name;
var&variable_name;
var&variable_name;

function Method_name()
{
body of method;
}

function Method_name()
{
body of method;
}

function Method_name(parameter_list)
{
body of method;
}

}

Object:-

  • Objects are defined from classes.
  • An object of a class a copy of each variable defined in the class is created.
  • Classes are nothing without objects.
  • We can create multiple objects from a class.

Syntax:-

$Object_name=new class_name;
Tagged : / / / / / / / / / / /