What Is PHP? Learning PHP, The Back-End Language of the Web

Updated on | Sign up for learn to code tips


What is PHP and why should you learn it? For anyone who wants to start coding, learning PHP can be a great first step. PHP coding is relatively easy to learn, used by lots of top companies, and is very versatile.

PHP is a server side scripting language used to create dynamic web pages. PHP language is open source, meaning it’s free to download and use. The language was created in 1994, so it’s been around for over 25 years. 

What does PHP stand for? Well, the PHP meaning is a little strange, because it’s a recursive acronym for “PHP: Hypertext Preprocessor” (yep, you read that right — PHP is part of the acronym for PHP!).

In this post, we’ll cover more about what PHP is, why you should learn it, what PHP development is used for, PHP syntax examples, the best way to learn PHP, and more. If you’re a complete beginner (whether to PHP or coding in general), you’re in the right place!

My friend Matt Trask joins me in this article to answer a few questions about PHP and provide info on how beginners can get started.

Table of Contents

Disclosure: I’m a proud affiliate for some of the resources mentioned in this article. If you buy a product through my links on this page, I may get a small commission for referring you. Thanks!

What is PHP?

PHP is a server side scripting language that is classified as a backend languageUnlike HTML or CSS, PHP does the heavy lifting behind the scenes. 💪

PHP code on screen

According to Matt,

“PHP can be used to create a connection to a MySQL, Postgres, or Mongo Database and quickly and dynamically create webpages. PHP can be used in either a browser or in the command line.”

Dynamic is an important word here. Dynamic webpages allow the user to interact with webpages. For instance, creating WordPress (WP) posts and changes.

PHP is a server side scripting language where the web server runs the script. This differs from client side scripting, where scripts are run on the user’s computer. For instance, JavaScript is a client side language.

Other examples of server side scripting languages include:

Moreover, PHP code can be mixed with HTML. It can also be used in combination with various web frameworks. Not only that, but PHP is part of several popular tech stacks, including:

  • LAMP (Linux, Apache, MySQL, and PHP)
  • WAMP (Windows, Apache, MySQL, and PHP)
  • XAMP (Cross-platform, Apache, MySQL, and PHP)  

PHP is an open source language, meaning it’s free to use. Download it here

We already explained that PHP stands for “PHP: Hypertext Preprocessor” — but why? Well, the original PHP meaning was “Personal Home Page” in its early days. As it evolved into a more complex coding language, it needed a new meaning for the name, but PHP as the acronym stuck!

Why Is PHP Coding Important?

PHP is the 9th most popular programming language, according to the TIOBE Programming Community index. While its popularity has slightly declined over the years, PHP language is still used by almost 80% of all websites!

Matt explains,

“Being the main language to craft CMS’s like WordPress, Drupal, PyroCMS, Anchor and others, PHP has shown that it is one of the primary web languages currently.”

PHP allows you to work with data and minimize your workflow. As Matt further elaborates,

“On top of that, you can set variables that display information. So instead of having to change 8 different titles, you can change one variable and have it affect the whole document. The way you can minimize your work flow is awesome with PHP.”

Start coding now

Stop waiting and start learning! Get my 10 tips on teaching yourself how to code.

Don't worry. I'll never, ever spam you! Powered by ConvertKit

What Is PHP Used For?

Seeing as PHP is such a widely used language, you may be wondering “What can I do with PHP?” Let’s dive into some of its most common applications.

PHP elephant plushie on laptop

Here are some PHP uses:

  • 💻 Web pages: Since PHP scripts can be embedded in HTML files to convert static websites into dynamic websites, it’s a great option for building web pages and websites. As mentioned above, PHP is used by almost 4/5ths of websites whose server-side programming languages we know.
  • 🛒 E-commerce stores: Many content management systems (CMS) like WordPress and Drupal, as well as e-commerce platforms like Magento and WooCommerce, are written in PHP.
  • 👩‍💻 WordPress themes and plugins: Since WordPress is written in PHP, you can use PHP to change the layout and design of different parts of a WordPress website.

Tons of companies use PHP development. For example, Slack currently uses PHP and Hack (a superset of PHP) for most of its server-side application logic. Facebook uses their own version of PHP called HHVM (HipHop Virtual Machine).

What Does PHP Look Like?

To get started as a learning PHP developer, you’ll first need to set up a local web server. Install these programs on your computer:

So, what does PHP look like? The first thing to know is that a PHP file contains HTML tags and PHP scripting code.

A PHP script starts with <?php and ends with ?>

To print out “Hello World” in PHP, it would look like:

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>

</body>
</html> 

Why Learn PHP? FAQs About Learning PHP

So, why should you learn PHP? And if you want to learn PHP, how should you go about it? In this section, we’ll quickly cover some of the important Q&As about how to learn PHP.

❓Who would benefit from learning PHP?

“Anyone!” Matt exclaims.

Because PHP is behind many popular platforms, it is beneficial to know some. (For instance, as a WordPress user, I have even dabbled with some PHP coding)! It is especially helpful for those looking to run a blog or an e-commerce store.

According to Matt,

“Knowing PHP lets you get behind the front end, and build up a blog the way you want, or change things in your online store. It gives you full control, so you don’t need to rely on WordPress theme devs, or an Etsy shop.”

Plus, today PHP has some awesome framework options to accompany it — like Laravel and CakePHP, just to name two. This means that you don’t have to even rely on a big name platform like WP or Magento to get going with PHP.

Person coding

Not only that, but PHP programmers can also earn a great salary. In fact, PHP developers earn an average of $91,624/year in the United States. So if you’re looking to pick up a skill that can help you earn more, PHP could be a good option for you!

🤔 Is it difficult to learn PHP? 

Compared with other programming languages, PHP is often considered easy to learn for people just starting to learn to code. 

If you already have a background in programming, PHP development should be especially easy to learn. But even if this is your first programming language, learning PHP is not difficult. The PHP language has really great, detailed documentation to reference and there are tons of online PHP tutorials and books, but it will still require effort to learn.

Thinking like a programmer, however, can take a bit longer to master, but this is not related to PHP itself and instead comes with time and practice.

⏰ How long does it take to learn PHP? 

How long it takes to learn PHP depends on how long and how often you study and practice. 

For instance, Coursera’s Building Web Applications in PHP takes approximately 31 hours to complete. Learn PHP by Codecademy takes about 25 hours. 

If you were to study two hours each day, for example, you could complete one of these courses in about 12-16 days. If you only have time to study on the weekends, say for three hours on Saturdays and three hours on Sundays, you could complete a beginner PHP course like the examples above in about 4-6 weeks.

PHP website

Keep in mind that online PHP courses for beginners can give you a great overview of the PHP language, including its basic syntax (i.e., the rules of the language), data structures, and other things like variables, logic, iteration, arrays, etc. If you’re a total beginner to coding, seeking PHP tutoring from a PHP developer may be a helpful supplement to self-teaching.

However, what really makes you into a skilled PHP developer is coding real projects and gaining real-world experience. And that, of course, will take longer than just mastering PHP language basics; you can expect anywhere from several months to several years.

📅 When should I learn PHP?

If you’re just starting your coding journey, you may be wondering when to learn PHP. Should you learn HTML/CSS first? Or a different programming language like JavaScript?

When learning PHP, it can be very helpful to have some basic knowledge of HTML and CSS, so my recommendation is to start with that. Prior knowledge of general programming concepts (e.g., functions, arrays, loops) can also be helpful, but is not necessarily required.

If you’re trying to decide whether to learn PHP or another programming language like JavaScript or Python, it really just depends on your goals. Read more about JavaScript here and Python here. Of course, you can always learn multiple languages. After all, it’s usually easier to learn another language once you know one!

Start coding now

Stop waiting and start learning! Get my 10 tips on teaching yourself how to code.

Don't worry. I'll never, ever spam you! Powered by ConvertKit

Where to Learn PHP

Check out these courses and tutorials to kickstart your PHP learning journey! 👇

  1. Learn PHP on Codecademy: In this 25-hour course, you’ll learn about functions in PHP so you can create your own reusable blocks of code. You’ll also learn about HTML form handling, conditional and logic, loops, form validation, and more.
  2. PHP for Beginners – Become a PHP Master – CMS Project on Udemy: This course has been taken by over 100K students and has a 4.4 star rating. Learn PHP with practical exercises and projects.
  3. PHP Fundamentals on Pluralsight: This course will teach you the foundations of PHP programming on the LAMP stack (Linux, Apache, MySQL, and PHP).
  4. Learn-PHP.org: Online, interactive PHP tutorial. Free.
  5. PHP The Right Way: Free online book. Translated into 10+ languages!

Another way to learn PHP is to immerse yourself in things beyond courses/tutorials. For example, check out these two PHP podcasts:

  • PHPTownHall: Hosted by Ben Edmunds and Phil Sturgeon, who talk about news in PHP
  • 3 Devs and a Maybe: Hosted by 4 guys, who discuss web development and frameworks with emphasis on PHP

And these PHP thought leaders:

Speaking of Jeffrey Way, his site Laracasts.com is worth every single penny. It is a more advanced course about Laravel and Object Oriented PHP.

Next Steps After You Learn PHP

There is no single “right” next step after learning PHP code — and some could argue that you’re actually never done learning it, as the language is constantly evolving! Once you’re comfortable with PHP, you’ll be able to build dynamic websites (and even land a PHP developer role if you work hard at it).

If you’d like to specialize in PHP, try your hand at more advanced PHP topics (e.g., patterns and design techniques, libraries, classes/objects). You could also learn backend PHP frameworks like Laravel, Zend Framework, or CakePHP.

No matter what direction you choose to go in, learning PHP adds one more skill in your arsenal to make you a more flexible and competitive developer.

About Matt Trask

Matt Trask has been a web developer for the past 2 years, starting with Codecademy.com and then moving to Teamtreehouse.com before getting his first job as a self taught web developer. Outside of the web, Matt enjoys getting lost in Harry Potter, Star Wars, finding new beers to try and playing a lot of tennis.

You can find him on Twitter at @matthewtrask or at matthewtrask.net.