All articles about Php 7

Null coalescing operator in PHP 7

Let us consider a code of checking the age first. It checks whether the ‘age’ is given in the form or not. If it’s not given, then it says ‘not mentioned’. When it’s given it just spits out the age. Very basic thing we normally did when php 7 had not come.

$age = isset($_GET['age']) ? $_GET['age'] : 'not mentioned';


As usual it’ll give an output of – ‘not mentioned.’ Now we write this code with the age given.

Continue reading Null coalescing operator in PHP 7

Inheritance, Encapsulation, Abstract Class and Interface in PHP 7

In Dictionary if you search the word ‘inheritance’, you’d land up finding this kind of description: …objects that someone gives you when they die.
In the programming world, it does not mean exactly the same in every sense but almost same if you take the literal meaning. Yes, there is a parent class with one or more child classes who inherit the objects from their parents but child classes are freer here, in the php programming world. These child classes are free to modify or override the properties and methods that they inherit. In real world it does not happen always.
Let us a have a simple code to check a parent class and child class.

Continue reading Inheritance, Encapsulation, Abstract Class and Interface in PHP 7

Hiding Information in PHP 7

If you have already read the previous blog, you should have noticed that there was a hole in the previous code.
Did you notice that?
Let us examine this part of code:

$guiter = new Instrument('Elictric Guiter');
$guiter->weight = 10;

And the output is simply mind blowing.

object(Instrument)#1 (2) {
string(15) "Elictric Guiter"

Continue reading Hiding Information in PHP 7

Overview of Classes and Objects in PHP 7

A class is a blueprint. A plan of doing something. Suppose we want to keep reviews through a class. Objects contain data and methods to send and receive messages.
It decides how a ‘review’ object will behave in future. Every object may not behave in the same fashion because one review may remain incomplete. You’ve to think every possibility before planning a class. It’s a good practice to have your pen and notebook ready so that you can write it down completely. What you’re going to do will be your flow chart. And the code you write inside your class will be your algorithm.
Now we have a ‘Review’ class.

Continue reading Overview of Classes and Objects in PHP 7

Composer-revolution and library of codes

Composer is a dependency management tool in PHP. For any PHP project you need to use your library of codes. Composer easily manages that task on your behalf helping you to declare those codes. You can also install or update any code in your library through composer. Please visit for more details.
In the opening page of, click the ‘getting started’ link.

composer home page
composer home page

In the above page you find two links – ‘locally’ and ‘globally’. It stands for two options. Suppose you don’t want to run composer globally or centrally in your system. In that case, you have to download and install composer each time for every project. But the global option is always preferable because once composer is installed in your system bin folder you can call it any time for any project.

Continue reading Composer-revolution and library of codes

Object Oriented Programming and PHP 7

Chapter 1. OOP and PHP 7

php7 in 7 days
php7 in 7 days

For absolute beginners, the term OOP or Object Oriented Programming may seem difficult. Some people want to mystify this term very heavily! Why? Because, the uninitiated PHP developers would never try to make their hands dirty and feet wet with code and will depend on them forever.
So the first step is start believing in your potentials, powers and strength of your mind. Coding is like writing. I show you how easy it is!
Consider a piece of writing where you’re trying to describe a robot. So in your writing ‘robot’ is the subject. In object oriented programming the ‘robot’ is the object. In your piece of writing, your subject ‘robot’ has some descriptions like – the robot has three eyes, two noses, six arms.
In OOP we need to write a class ‘Robot’ which has those properties like this:

arm = $arms;
        $this->eye = $eyes;
        $this->nose = $noses;
        echo "The robot has {$eyes} eyes, {$noses} noses, {$arms} arms";
//class ended
$robot = new Robot();
$robot->showRobot(3, 2, 6);

Continue reading Object Oriented Programming and PHP 7

How to upgrade to PHP 7

php7 in 7 days
php7 in 7 days

I presume you’re running php 5.x on an Ubuntu 14.04 machine. If you’re windows based, you can easily install Ubuntu 14.04 as a second operating system.
Remember, a genuine php programmer should know a little bit of Linux programming. It’s extremely easy and user friendly. Install Ubuntu on your system and open the terminal by pressing ‘control+alt+t’. For further association with Linux there are tons of free resources available over the internet.
You’ve opened up your terminal; now type this command on it.

sudo add-apt-repository ppa:ondrej/php

A Personal Package Archive, or PPA, is an Apt repository hosted on Launchpad. PPAs allow third-party developers so that they can build and distribute packages for Ubuntu outside of the official channels. They’re often useful sources of beta software – php 7 is also on the developmental stage and it’s not ready for the production environment.

Continue reading How to upgrade to PHP 7