Skip to main content

OOPS Features Supported by PHP

>> OOPS Features Supported by PHP

  •  Class
  •  Object
  • Constructor and Destructor
  • Inheritance
  • Encapsulation

Class
The class is a programming block structure contains its own properties and methods to process the domain functionalities. We can create instances to a class to access its properties and method.

Object
Objects or Instances can be created for a class to access the class components.

Constructor and Destructor
The Constructor is a class function called automatically when an instance is created for that class. The Destructor is a function that is invoked when the class instance is destroyed.

Inheritance
There are three types of inheritance like single, multiple and multi-level inheritance. PHP supports single and multi-level inheritance. It will not support multiple inheritances. That is, A class can extend only one parent class. To overcome this limitation, PHP provides the Traits concept which allows us to use functions of one class into one or more classes.

Encapsulation
Since properties and methods of the objects are enclosed with the class container in an abstract manner, any code from outside cannot access the class, unless otherwise by using objects of that class. In this way, the properties are encapsulated.
>> What is Store Procedure?
A stored procedure is a named collection of SQL statements and procedural logic i.e, compiled, verified and stored in the server database. A stored procedure is typically treated like other database objects and controlled through server security mechanism.

Instead of writing code in PHP we can write stored procedure/functions as those are stored in compiled format those executes faster than PHP codes.

DELIMITER //
CREATE PROCEDURE `employee_pro2`(IN `empemail` VARCHAR(50), IN `empname` VARCHAR(50))

BEGIN
SELECT employee_id, name, email_address FROM employee WHERE email_address = empemail and name = empname;
END
// DELIMITER ;


DROP PROCEDURE employee_pro4

>> Dependency injection is a technique whereby one object supplies the dependencies of another object. A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it.

>> Type Hinting in PHP. Since PHP 5 you can use type hinting to specify the expected data type of an argument in a function declaration. When you call the function, PHP will check whether or not the arguments are of the specified type. If not, the run-time will raise an error and execution will be halted.

>> Getters and Setters are object methods that allow you to control access to a certain class variables / properties. Sometimes, these functions are referred to as “mutator methods”. A “getter” allows to you to retrieve or “get” a given property. A “setter” allows you to “set” the value of a given property.

>> Final

The methods or classes can not be modified by a child class. This prevents class inheritance, method-overriding and/or redefinition of methods.
Only class definitions and/or methods inside a class can be defined as final.

>> Static

Declares class methods or properties as a static value so that you have access to them without instantiating an object. These are shared between parent and child-classes.
A class definition can not be static unlike final.

The size of all cookies should not exceed 4KB.
You can store as much data as you like within in sessions. All sessions are stored on the server. The only limits you can reach is the maximum memory a script can consume at one time, which by default is 128MB.


>> What is memcache?
Free & open source, high-performance, distributed memory object caching system
Memcache is an in-memory key – value pair’s data store (data store in the memory in the form of key - value)

Pros:
  • Data store in memory so its mush faster.
  • Reduce database load.
  • Perfect for website with database load.
  • Reduce the number of request to database
Cons:
  • Not a persistent store
  •  Cant cache large objects (Max value 1 MB)
>> What is Memcache
Memcache is high performance distributed memory object caching system. Intented to speedup web applications and reduce database load. Memcache is key value dictionary of string, objects, etc stored in memory resulting from database call, API calls and page rendering.

Feature:
It reduces database load
Efficent for websites with high database load.

>> Which port is memcache is using.

11211

>> What is Serialization?

Serialization Is the process of converting an object into a stream in the form bytes.
Deserialization is the process of reconstructing an object that has been serialized before.

Comments

Popular posts from this blog

Learn phpfox

PHPFox  is a social network script, it is an internet application and when you install it, it is a website. The  phpfox  script comes in 3 packages, each with a different set of modules. it has two products: 1. Nebula (upto phpfox 3.8) 2. Neutron (Newer) You can check the demo on :  http://www.phpfox.com =================================================== To clear cache in phpfox follow the following steps, admincp >> Tools >> Maintenance >> Cache Manager >> Click on Clear All button =================================================== To work facebook app on local Following settings need to done in facebook app   1) go => setting => Advance 2) see "OAuth Settings" area and set "Valid OAuth redirect URIs" =  http:// projectdomain /index.php?do=/user/login/, http:// projectdomain .com/index.php?do=/user/register/, http:// projectdomain .com, http:// projectdomain .com/index.php 3) en...

Interview PHP

>> Why do you want to work at our company? Sir, It is a great privilege for anyone to work in a reputed company like yours. When I read about your company I found that my skills are matching your requirements.  Where I can showcase my technical skills to contribute to the company growth. >> What are your strengths? I am very much hard working and optimistic. Hard Working: Work with dedication and determination. Optimistic: work with positive attitude. I am a team player. I am also very hardworking, and will do what it takes to get the job done. >> What are your weaknesses? Gets nervous when talk to strangers I am a bit lazy about which I am not interested I tend to trust people too easily. I am working on it. >> Why should I hire you? With reference to my work experience, I satisfy all the requirement for this job. I am sincere with my work and would never let you down in anyway. I promise you will never regret for the decision to a...

How to Make Your Own PHP Captcha Generator

In this article we will create file based simple yet successful captcha generator. 3 Major Anti-spamming techniques used? Mathematical Operation like Random number + Random Number = -> The user must specify the answer Random word -> User must type the word Random question -> Obvious one which the user should answer correctly [ex: Are you human?] How Captcha works? The captcha generator generates an IMAGE with the question and then put up a session variable storing the value. User input though an input box. Using php POST, we compare the session variable data with the user input and tell whether its a bot or human. Its coding time The Code First let's write the php script which generates the captcha image. We use the simple header-content change technique, from which we can easily bring up an image from a given text. captcha.php PHP Code: array("Num" => "Num"), 1 => array("Are y...