Lets First, know about the PHP

PHP represents for Hypertext Pre-processor, PHP is a server-side scripting language. that is used to develop Static sites or Dynamic sites or Web applications. PHP is designed by Rasmus Lerdorf and developed by PHP Development Team, Zend Technologies.

  • PHP is a generally utilized, open-source scripting language
  • It is free to get and use
  • PHP files contain text,and PHP code, HTML, CSS, JavaScript
  • It’s code is executed on the server, and the outcome comes back to the program as plain HTML

What Can PHP Do?

  • PHP can produce the dynamic page content
  • It can make, open, read, compose, erase, and close documents on the server-side
  • PHP can collect form data
  • It can send and receive cookies
  • PHP can include, erase, alter information in your database
  • It can be used to control user-access
  • PHP can scramble information

With PHP you are not limited to output only HTML. You can also get output of images, PDF files, and even Flash movies. You can output any text, such as XHTML and XML too.

So Let’s Come To The Point – What Is PHP OOPS?

Object Oriented Programming, or OOP, refers to the method of programming that invokes the use of classes to organize the data and structure of an application. With PHP, OOP started to become with the release of PHP 4, but really came into its own with PHP 5.

Why OOPS In PHP?

Object oriented programming a technique to design your application. An application could be any type like it could be web based application, windows based application. OOP is a design concept. In object oriented programming (OOP), everything will be around the objects and class. By using OOP in PHP you can also create the modular web application. By using OOP in PHP we can perform any activity in the object model structure ( Treats an XML or HTML document as a tree structure). There are many benefits to using oop. some of them:

  • Code Re-usability
  • Code Maintainability
  • Abstraction
  • Molecularity

What Are The OOPS Concepts In PHP?

  • Class − This is a data type -defined by a programmer, which includes local functions as well as local data. a class is template definition of the methods and variables.
  • Object − Objects are the things you think about first in designing a program and they are also the units of code that are last derived from the process. In between, each object is made into a generic class of the object and even more, generic classes are defined so that objects can share models and reuse the class definitions in their code. an object is an instance of a particular class or subclass with the class’s own methods or procedures and data variables. An object is what actually runs in the program.
  • Member Variable − Member variables are the variables defined inside a class. Data will be not visible to the outside of the class and can be accessed via member functions. These variables are called attribute or property of the object once an object is created.
  • Member function − These functions defined inside a class and are used to access object data.
  • Inheritance − When a class is defined by inherite existing function of a parent class then it is called inheritance. Here child class will inherit all or a few member functions and variables of a parent class.
  • Parent class − Class that is inherited by another sub class. This is also called a base class or superclass.
  • Child Class − A class that inherits from another class called a subclass or derived class.
  • Polymorphism − This is an object-oriented concept where the same function may be used for different purposes. For example, the function name will remain the same but it makes take the different number of arguments and can do different task.
  • Overloading −  is a type of polymorphism in which all or some of operators have different implementations and it’s depend on the types of their arguments. Similarly, functions can be overloaded with a different implementation.
  • Data Abstraction − is a representation of data in which the implementation details are hidden.
  • Encapsulation − refers to a concept where we encapsulate all the data and member functions together to form an object.
  • Constructor − It is a type of special function that will be called automatically whenever there is an object formation from a class.
  • Destructor − refers to a specific type of function that will be automatically asked if whenever an object is removed or out of the scope.

A Basic Example Of Using Class

<?php
class clsMakeCoffee {

public $step1;
public $step2;
public $step3;
public $step4;

public function PrintRecipe() {

echo $this->step1." <br> ".$this->step2." <br> ".$this->step3." <br> ".$this->step4;
}

}
$obj = new clsMakeCoffee();

$obj->step1="1. Take One cup of hot milk";
$obj->step2="2. One to two Teaspoon of sugar";
$obj->step3="3. One Teaspoon Of coffee";
$obj->step4="4. Mix well all ingredient and enjoy your coffee!!";

$obj->PrintRecipe();
//Output :
1. Take One cup of hot milk
2. One to two Teaspoon of sugar
3. One Teaspoon Of coffee
4. Mix well all ingredient and enjoy your coffee!! ?>

OOPS And WordPress

WordPress is a very old software project. A lot of it was written by people who weren’t totally sold on object-oriented PHP, or during a time in which object-oriented programming wasn’t yet the de facto standard for high-quality code. As such, the object-oriented WordPress systems that do exist are in an environment of a lot of other WordPress code that isn’t object-oriented.

But some parts of WordPress are object-oriented, and they’re important: from widgets to WP_Query to the REST API, and also including just about everything in a number of important WordPress software extensions such as WooCommerce.

 

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.