All articles in PHP 7 in 7 Days

Custom Post Type in WordPress for PHP Developers

Sometimes you need a custom post type in your WordPress application. Let me explain why you need it first? Wordpress … More Custom Post Type in WordPress for PHP Developers

How to start MySQL in Linux terminal

Very simple step. Type this command on your terminal:

mysql -u root -p

It’ll ask for your password that you had given while installing mysql on your Ubuntu machine.
Give the password and it’ll show something like this:

Continue reading How to start MySQL in Linux terminal

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

Adapter Pattern in PHP

Can we Adapt SMS into MAIL?
Now we’re going to do an impossible task.
Are you prepared?
Can we start?
This chapter is about the adapter pattern. It’s one of the design patterns that you’re currently on. Let us start with a real world example.
You know that internet connection is absolutely necessary for sending emails. Is it true in the real world? You’d say, well, I know that. An internet networking is a must.

Continue reading Adapter Pattern in PHP

Chain of responsibility in php

Let us see how Responsibility can be Unchained!
In object-oriented design, the chain-of-responsibility pattern belongs to behavioral design patterns segment. The simplest example contains a person using ATM. He’s entering pin, receiving payment and receipts etcetera.
What is behavioral design pattern? They are a type of design patterns that generally identify communicating objects.
You may ask, what kind of objects we’re talking about? These objects have common communication patterns between them. While communicating they must realize that patterns.

Continue reading Chain of responsibility in php