What is PHP?

PHP is a general-purpose scripting language mostly used to create web applications. The word PHP is a recursive acronym for PHP: Hypertext Preprocessor. PHP is different from client-side scripting languages like JavaScript or Typescript in a sense that the code is executed on the server, unlike client-side scripting language which runs on the client side.

PHP code can be embedded into the HTML page, and after the execution, it will generate HTML which is sent to the client. The client will only be able to see the HTML and would not know the PHP code behind the HTML.

The best thing about PHP is it is not only easy to learn but also offers powerful advanced features to help professional developers to create feature-rich web applications.

You can start learning PHP even if you are not a professional programmer. The only pre-requisites to learn PHP is having some knowledge of how the internet works and how to write HTML pages.

PHP 7.3

The biggest strength of PHP is its large community which works hard for the rapid updates being pushed out now and then.

Since the release of PHP 7.0, the community has seen a lot of new features that have significantly improved the speed and performance of the web applications written in PHP. The latest version has come up with some much-needed security and performance updates.

Why should you learn PHP?

In recent few years, many new programming and scripting languages have joined the programming horizon, but still, PHP holds a significant share in the market. It powers over 200 million websites over the internet. Undoubtedly, PHP is one of the fastest-growing web development languages.

You should learn PHP because

It is a free and open-source scripting language

It has a short learning curve compared to many other web development languages

The PHP community is huge which means instant support whenever you get stuck

PHP is regularly updated

PHP is a cross-platform scripting language

With PHP you are not limited to output HTML. You can output images, PDF files. PHP can generate images and text on the fly

PHP is really easy to work with databases. When PHP allies with MySQL to access or store data, you have the power to create powerful data-oriented web applications.

PHP let you write code in a procedural or object-oriented way which gives you enormous control on the code

Almost every web hosting service provider supports PHP and MySQL

PHP has built-in support for web services.

Who should learn PHP?

This course is for anyone interested to learn web development or server-side scripting language in general. You don’t have to be an expert programmer to learn it. This course is divided into easy-to-understand lessons with real-world PHP coding examples. You can learn while being at home or office at your own pace.

To learn each concept, you must follow the order of these lessons. Once you understand the idea, you can move on to the next one.

PHP System Requirements

PHP 5.5+ require at least Windows 2008/Vista, or 2008r2, 2012, 2012r2, 2016 or 7, 8, 8.1, 10. Either 32-Bit or 64-bit (aka X86 or X64.). For PHP 7.2.0 Windows 2008 and Vista are no longer supported.

Installation of Apache, PHP, MySQL

To run PHP, you need to install an interpreter on your machine first. You can install PHP manually, or you can use programs like wamp, mamp or xampp to create a local development environment. This step will give you everything you need to develop web applications in PHP: a Local web server to execute the .php files, SQL databases and other utilities like PhpMyAdmin, access to the root directory to store your project files.

There are few click-to-install software packages which let you create a development environment. I would recommend you to try xampp or wamp (mamp in case you are using Mac).

Install XAMPP

You can download xampp from here. ( https://www.apachefriends.org/download.html) Xampp is entirely free, easy to install Apache distribution software. It supports Windows, Linux and OS X.

Download and click the .exe file to start the installation process. After installing xampp, you have to start Apache, MySQL manually as you can see in the screenshot.

Install an IDE or code editor

An IDE or Integrated Development Environment is a self-contained software package that helps you to write, compile, execute and debug code in the same place. Choosing the right IDE is essential when you are trying to create and maintain a high-quality code. You can skip the IDE in favor of code editor if you are at an advanced level and knows what you are doing. A code editor is a text editor with several features to facilitate the process of writing code, but don’t have any other functionality to execute the code. Code editors are a more general purpose as compare to the IDE.

Both IDE and code editors provide useful features like code completion, highlight syntax or sections of code, branching or automated closing of brackets. But the code editors are limited to writing code and do not go beyond this. Choosing between an IDE or code editor is more like a personal choice and depends on how you prefer to manage project files.

Some top IDE for PHP projects are:

  • PHP Storm
  • NetBeans
  • Aptana Studio
  • Eclipse
  • Zend Studio

Some top code editors for PHP projects are:

  • Sublime Text
  • NotePad++(My favorite)
  • Atom
  • Coda
  • Brackets

Notepad++ is multi-purpose code editor. You can write code in PHP, Perl, C, C++, Assembly, and so many other languages in this editor. It is an open source and free to use the software.

Your First PHP Program

You are now ready to start writing PHP code. In our first example, we will create a program that will print hello world.

Open your favorite code editor or IDE (create a project first) and copy paste the following code. Save the file as “hello.php” in the htdoc folder.

Now, open a web browser and type localhost/hello.php in the address bar. It will open an HTML page that shows text Hello World.

PHP Example: 1

       echo “Hello World!”;


Code Explanation

The PHP code starts from <?php and ends at ?>. This what would tell the interpreter that there is a PHP code block inside these symbols. We will discuss these in detail in upcoming lessons.

This code above is a typical PHP statement. A PHP script is comprised of a series of commands or statements. In PHP statements are always terminated with a semicolon.

echo “Hello World!”;

This code is an echo statement, which is used to display text. You can replace this hello world string with your name and see what happens.

Dos and Don’ts when learning PHP

To become a PHP web developer, you need to adopt at least these four things.

A routine or schedule to learn – If you are not consistent about your learning routine or have no fixed schedule, you may face lots of difficulties to focus.

Practice – Reading or watching tutorials online won’t help you unless you attempt these coding examples by your hands. So try to practice every coding example provided by this course yourself.

Patience – You may get frustrated at some point due to errors or hours of code review to find which semicolon you missed, but this is how you learn to programme. Even after all these years of programming experience, I still have to struggle with code sometimes. So don’t give up if you get stuck. Give yourself a ten-minute break and starts again.

Use references –  Always refer to the documentation for the syntax reference for the updated information.

So what are the Don’ts of learning PHP?

Don’t get disappointed – If you are new to programming, you may get discouraged easily by the people around you. They will tell you that PHP is dying or going to be replaced by some xyz language. PHP holds a sufficient share of websites over the internet, and it will take years for some language even to take a small portion of php’s share.

Don’t give up – Don’t give up on PHP just because your neighbor think that web development is not good enough. PHP isn’t just about web development. Due to its more manageable learning curve, it teaches you the fundamental concepts of programming like variables, array, constants, object-oriented programming.

Don’t be in a hurry – Don’t try to learn PHP in one day. Although you will find courses or material on the internet that promise to teach you PHP in one day, going over the concepts or skipping the basics isn’t just a good idea. Take your time and learn every theory before moving on to the next lesson.

Don’t skip lessons or practice – PHP, just like the most programming language, requires a commitment and good time management to get the best out of it.

PHP Syntax
Last modified: April 4, 2019