Browsing category PHP

PHP Inheritance


Inheritance allows child classes to use its parent class members. This is very useful when you want to have common functionalities for most of the child classes in the base class. Inheritance in PHP:

  We are going to create a base class called “greetings” which will have a “check_date()” method to check the

PHP Constructor and Destructor


Both constructor and destructor are PHP’s magic methods. Constructor: The constructor function will be automatically called when we instantiate an object when it is being initialized. PHP’s constructor should be defined as: In PHP 5 and above:

    In PHP 4:

Here “yourclassname” must be your actual class name where you have

PHP Abstract Class


PHP’s abstract class is a base class which will have abstract methods with no definition. Abstract classes cannot be instantiated or in other words, you cannot create an object of an abstract class. An abstract class can have non abstract methods also. Class which has at least one abstract method should always declare as an

PHP Multiple Inheritance using Traits


The problem of multiple inheritances in PHP will occur when two classes are having same method. This can be avoided using “traits”. This feature is available from PHP version 5.4.0 Simple Multiple Inheritance using Traits:

 

PHP Interface


PHP’s interface is very useful when you want to implement common functionalities in all the classes which implements interface. Which is a workaround for multiple inheritance in PHP. This is very useful when you don’t know what the member methods body will have inside. PHP multiple inheritance using Interface: Here we are going to make

PHP OOP – Class example


Like other programming languages, PHP is also support Object Oriented Programming with Overloading, Data Abstraction and Encapsulation etc. The latest version of PHP supports Namespaces which is similar to “Package” concept in Java. A simple PHP Class:

 

PHP 5.6.7 is ready to download


The PHP dev team has announced the release of PHP version 5.6.7, which has many bug fixes for ZIP lib, SOAP, SPL, PGSQL, OpenSSL, Opcache, FPM, ODBC, Curl,  CGI and CLI. The following bugs are fixed in PHP 5.6.7: ZIP Integer Overflow __call() method confusion in SoapClient through unserialize() function Storing infinite values in pg_update()