PHP OOP – Constructor

Constructor in PHP is special type of function of a class which is automatically executed as any object of that class is created or instantiated.

PHP – The __construct Function

PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.

PHP OOP - Constructor


PHP OOP – Classes and Objects

A class is a template for objects, and an object is an instance of class.

Object Oriented Concepts

Before we go in detail, lets define important terms related to Object Oriented Programming.

  • Class − This is a programmer-defined data type, which includes local functions as well as local data. You can think of a class as a template for making many instances of the same kind (or class) of object.
  • Object − An individual instance of the data structure defined by a class. You define a class once and then make many objects that belong to it. Objects are also known as instance.


PHP – What is OOP?

Object-Oriented programming is faster and easier to execute. From PHP5, you can also write PHP code in an object-oriented style.

PHP What is OOP?

OOP stands for Object-Oriented Programming.



How to Create Custom Image File Explorer in PHP

A file explorer, specially designed for showcasing image files will be a cool addition to your PHP web application when you are handling images.

Imagine an image file explorer built in PHP with options to options to browse files in icon, list and detailed view. That is what we are going to see and build in this article.

Having feature to explore image files with different modes of display will enrich your web applications. Image gallery is a popular choice but if it comes added with other views, it will be a definite win for the users.Custom Image File Explorer in PHP

jQuery Plugin For Folding Tree Structures – file-explore.js

jQuery Plugin For Folding Tree StructuresFile-explore.js is a minimal jQuery folder tree/file explorer plugin used to convert nested unordered lists into a hierarchical tree that is both expandable and collapsible.

How to use it:

1. Add the jQuery file-explore plugin’s files to the webpage which has jQuery library loaded.

<link href="css/file-explore.css" rel="stylesheet">
<script src="//"></script> 
<script src="js/file-explore.js"></script> 


File Explorer-like Tree View Plugin For jQuery – explr-js

File Explorer-like Tree View Plugin For jQueryexplr-js is a jQuery plugin that converts nested html lists into a File Explorer-like hierarchical tree with smooth animation and custom icons support.

How to use it:

1. Load jQuery library and the jQuery explr-js plugin’s files in the html file

<link href="jquery-explr-VERSION.css" rel="stylesheet">
<script src="//"></script>
<script src="jquery-explr-VERSION.js"></script>


Multiple File Upload using PHP

In this tutorial, we are going to see how to upload multiple files using PHP. I am using “Fine Uploader” a JavaScript, open source and free library. Also, fine-uploader has no dependencies. It is simple and easy to understand. It shows a progress bar during upload and preview for the uploaded files in a gallery form.

Multiple File Upload

Split and Export into Multiple Excel Sheet Files using PHP

When we are dealing with huge volume of records export into excel or CSV, we cannot blindly export them into a file. Imagine we have a million records, what would happen if we export those records into a single excel file! In this kind of situation, we should group the records and split them into multiple files so that it will be easy to handle them.

Split and Export into Multiple Excel Sheet Files using PHP

Access MySQL from PHP

In this tutorial, we are going to access MySQL database from PHP. Accessing MySQL from PHP is very simple and easy to implement. PHP contains built-in functions to connect the MySQL database and to access the data. Those functions are,

  • mysqli_connect – To connect the database by using the specified configuration.
  • mysqli_query – To execute a query to get resource id.
  • mysqli_fetch_row – To read row data with the reference of the resource id. There are many MySQL fetch functions in PHP to read table rows.

I have added an example code for accessing MySQL database from PHP. I used the database table named animals on which the create, read, update and delete (CRUD) functionalities are going to be performed.

Access MySQL from PHP

Sage Pay Payment Gateway Integration using PHP

Sage Pay payment gateway integration is easier to implement in websites. Sage Pay provides API access for requesting payment process from our website. This type of payment integration can be done in three ways using Sage Pay checkout pages, Sage Pay drop-in checkout and using own form. People having experience in any kind of payment integration (PayPal) can find it easy to follow the API documentation for integrating Sage Pay. If you are a newbie for payment integration, this article will help you to start with a simple example for integrating Sage payment in the test environment.Sage Pay Payment