An Introduction to PHP 7 book

php 7
php 7

I had started writing a well documented book on PHP 7 in the month of March but I’d to leave the project unfinished as situation demanded.
I’m eager to go back to my unfinished job. Before that I thought it would be good for my readers to give them a glimpse of how I had started it.

Note from Author

I always love to write for the beginners. I love the innocent moments of bringing few new things to my dearest readers. And this time I’ve done it by taking a completely different approach. You build web applications and learn php 7 simultaneously.
Continue reading “An Introduction to PHP 7 book”

How to become a good PHP developer

I want to answer this question from a beginner’s perspective. You’re reading this article because you’re a PHP developer with little knowledge and you want to make ‘coding as your forte’.

php developer
php developer

Closed or Open?

I’ve seen two sides of server side scripting. I had started learning PHP and MySQL much before I tried coding in C# and ASP.NET. I had not been developing with ASP.NET for long because I’d to leave it. Was it destiny? Actually I didn’t like the closed source. That was the real reason. Besides it was not my profession. I was not a professional PHP developer at the beginning. I was a data-journalist who wanted to be an Author and Ethical Hacker.
Continue reading “How to become a good PHP developer”

How I joined multiple Bootstrap themes with my official WordPress site

Bootstrap CSS and WordPress

I thought I should write down this without delay and share with my readers. These are bits and pieces of my experiences of writing my official website sanjibsinha.com. It was a kind of trial and error method that I had always expected that, well – touch wood, it’d survive somehow. In this article I show how multiple themes can be added with wordpress by using Bootstrap CSS styles.
And it survived the experiments. Google started indexing it and I think the time has also come to play with Google analytic.
Continue reading “How I joined multiple Bootstrap themes with my official WordPress site”

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->setWeight(1);
$guiter->getWeight();
$guiter->weight = 10;
var_dump($guiter);

And the output is simply mind blowing.

object(Instrument)#1 (2) {
["name"]=>
string(15) "Elictric Guiter"
["weight"]=>
int(10)
}

Continue reading “Hiding Information in PHP 7”

Getter and Setter in PHP 7

Get, Set and Go…

In any class the properties play very roles. Till now we use ‘public’ before every property. In the real world the situation may not be same.
Imagine an ‘Instrument’ class. In the construct part you can pass the name of the instrument. Besides, you can have a property – ‘weight’. Let us write the code first and see the output.

Continue reading “Getter and Setter 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 https://getcomposer.org for more details.
In the opening page of https://getcomposer.org, 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:

//Code/php7book1/index.php
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”