আগামী ৩০ নভেম্বর-২০১৭ তারিখ থেকে শুরু হচ্ছে পাঁচ মাস ব্যাপী Professional Web Design and Development with HTML, CSS PHP,MySQL,JavaScript, AJAX, JQUERY, Bootstrap and Live Project কোর্সের ৮৭ তম ব্যাচ এবং ৫ ডিসেম্বর-২০১৭ তারিখ থেকে শুরু হচ্ছে চার মাস ব্যাপী Zend PHP-7 Certified PHP Engineering (Advance PHP) কোর্সের ৩৫ তম ব্যাচ। প্রত্যেকটি কোর্স এর ফী নির্ধারণ করা হয়েছে ৩০,০০০/= আগ্রহীদেরকে অতিসত্বর মাসুদ আলম স্যার এর সাথে যোগাযোগ করতে অনুরোধ করা যাচ্ছে। স্যার এর মোবাইল: 01722 81 75 91

PHP Object Oriented Programming Part I: PHP OOP Basics

Introduction to Object Oriented Programming:

PHP OOP Class and Object

To understand object oriented programming, we first need to know what is object? And what is class?

What is Object?

Everything we see around us is object. Suppose you look at yourself and your surroundings, your coat, your pants, mobile, tables, chairs, computers all these are objects. Even you and I myself are an object

What is Class?

Now we know about object. Let’s know about class. A class is the replica of an object or the blueprint of an object. Suppose we want to make a chair. At the beginning, we can not make a chair without any thought. We plan for it – what will be the chair looks like, how much will it be in length, width and height etc. These plans are what we write somewhere as document. Our document is actually a class. To explain a little bit more, we can say that the name of the object is determined by the name of the class. The object created by a class is called an instance of that class.

What is Object Oriented Programming?

Now the question is, what is Object Oriented Programming? Object Oriented Programming is a computer programming which is defined by using the concept of class and object is called Object Oriented Programming. Object Orient theory is founded by three concepts:

  • Inheritance– Inheritance is a method of sharing some of the functionality and properties from one class to another class. Or Inheritance is a process in which, any class or object attains the characteristics of any other class or object. It is easier to say that, The Inheritance is a process where a child class inherits some of the features from its parent class.

  • Encapsulation– That means, all things remain encapsulated. Much like capsule medicine. Just like a capsule is wrapped inside a vein. Similarly, in Object Oriented Programming, everything is covered with a cover of a class.

  • Polymorphism– Multiformity. That is, an object can take many forms at different times and can be used in many ways.

What are the things to know before learning Object Oriented Programming in PHP?

Before learning Object Oriented Programming in PHP, what are the things to know?

  • Parent Class: When a class inherits from another class, then the class from which the new class is created, is called parent class. Parent class is called base class or super class.
  • Child Class: When a class is inherited from another class, it is called child class. The child class is called subclass or derived class
  • Visibility/Access modifier: Any property, constant or method in class can be accessed with visibility. Visibility is usually declared in class by constant, property, method before the announcement.

    Three types of visibility in PHP:

    • private: If the constant, property, method in class is to restrict the usage of only the same class or class, then those constant, property, methods are to be declared private.

    • protected: If constant, property, method in class is to restrict the usage of only the same class or class itself and its child class, then those constant, property, methods are to be declared protected.

    • public: If you want constant, property, methods in class, use the same class or class itself, child class and class outside, then those constant, property, methods are to be declared public.

  • Property: Variables in the class in PHP are called properties. Properties are also called “attributes” or “fields”. Property in PHP is to define with any one visibility: public, private, protected.

  • Method: Functions in class in PHP are called method. The methods in PHP are to declare with any one of the visibility: public, private, protected.

  • static keyword: If you want to give access to any property or method without any instance or object, or if you want to access it directly by class, then static keyword is used.

  • “::” scope resolution operator: To use any static property, static method and constant in the class in PHP, use “:: scope resolution operator” if you want to use it inside or outside the class.

  • “$this” pseudo-variable: “$this” pseudo-variable originally contained the object of the current class. If you want to use any non-static property in PHP and non-static method within the class, you need to use “$this” pseudo-variable.

Hi, My name is Masud Alam, love to work with Open Source Technologies, living in Dhaka, Bangladesh. I graduated in 2009 with a bachelor’s degree in Engineering from State University Of Bangladesh, I’m also a Certified Engineer on ZEND PHP 5.3, I served my first five years a number of leadership positions at Winux Soft Ltd, SSL Wireless Ltd, CIDA and MAX Group where I worked on ERP software and web development., but now i’m a co-founder and Chief Executive Officer and Managing Director of TechBeeo Software Consultancy Services Ltd. I’m also a Course Instructor of ZCPE PHP 7 Certification and professional web development course at w3programmers Training Institute – a leading Training Institute in the country.

One comment on “PHP Object Oriented Programming Part I: PHP OOP Basics

Leave a Reply

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