!Deprecated notice:

Courses have been deprecated. Now there won't be any more courses on Codeguage. The learning model has now changed from a course-based platform to a practice-based platform. For practice, head over to the page showcasing practiceables.

PHP

A backend scripting language to create web applications

Beginner
15 hrs 31 mins
35 chapters

Overview

PHP, which stands for PHP: Hypertext Preprocessor, is a powerful scripting language conceived of helping developers easily create the backend of a web application.

It is a server-side language that powers over 75% of websites out there whose backend programming language is known, according to this report on W3Techs.

PHP is a high-level interpreted language that is much like the C programming language in terms of syntax and semantics. A person familiar with C, or any C-style language will have no problem in understanding PHP. However, even without any prior knowledge of programming, PHP is a very good choice as the very first programming language for any beginnger, although a knowledge of HTML and JavaScript really helps in the longer run.

PHP has a large scope for jobs. There are many frameworks built around PHP to ease web development such as Symfony, Laravel, CodeIgniter. This is evident of the fact that knowing PHP improves your portfolio and increases your chances of landing at a good job. Some big names out there use PHP to power their web applications. To name a few, we have Facebook, Wordpress, MediaWiki and Drupal.

The best part about PHP is that it is extremely simple to learn, yet extremely powerful and robust. We can do anything in PHP that we can do in any other sophisticated language. You name it — file handling, image processing, PDF processing, multithreading — everything can be done in PHP.

Prerequisites

  • HTML

    Routinely in this course, we'll construct HTML markup to create various kinds of applications. Prior knowledge of HTML is thus a clear-cut requirement.

  • CSS

    Although CSS isn't directly associated with PHP, we'll also routinely use it to style our HTML markup.

  • JavaScript

    Although JavaScript isn't directly associated with PHP, we'll use it sometimes to interface with the server side asynchronously.

Learning outcomes

By the end of this course, you will know:

  • How to install and set up PHP on your computer, code PHP programs in VS Code, and execute them using the PHP interpreter.
  • How to create simple CLI programs by reading from and writing to standard input and standard output, respectively.
  • How to work with common data types in PHP, including integers, floats, strings, Booleans, arrays and functions.
  • How to develop programs following the procedural paradigm.
  • How to reason about programming problems and construct efficient solutions for them.
  • How to work with some advanced features of PHP, such as references, closures, string formatting, and how to use them in solving real-world problems.

Table of contents

  1. In this unit, we'll cover all the foundational ideas of PHP including how to set up the environment to write and thereby execute PHP scripts. We'll learn about such things as variables, strings, integers, floats, data types and much more. We'll see how to write output to the terminal and retrieve input via the terminal. We'll explore functions, operations and PHP's control flow structures, in addition to the concept of variable scoping.

  2. In this unit, we'll explore the world of numbers in PHP. We'll get to know about the internal representation of integers and floats, the exponential notation and the symbol E, how to round numbers, how to obtain random integers and much more.

  3. Strings are the cornerstone of modern-day programming. In this unit, we'll unravel all the aspects of working with strings in PHP, starting with the very basics, then moving over to concepts such as padding which is used a lot in formatting terminal output. Lastly, we'll explore string functions in PHP and then end with a final unit quiz.

  4. Control-flow is used to refer to features of a language that affect the flow of control (execution) while running a program. In this unit, we'll cover the most common control-flow statements in PHP, starting with conditional statements: if, else, elseif, and switch, and then ending with iterative statements: for, while, and foreach.

  5. This unit is all about one of the most useful data types in all languages — arrays. After getting a quick recap of what we learnt thus far regarding arrays in this unit, we'll be kicking into high gear. In particular, we'll explore associative arrays, array operators, common and advanced array functions, multidimensional arrays, array destructuring and unpacking, and how to sort arrays.

  6. In this unit, we explore functions, an integral part of programming. We'll start by reviewing some basics of functions in PHP and get to know of a couple of gotchas related to functions. Next, we'll dig deeper into working with functions parameters and arguments in PHP. The unit will reach its end with a thorough discussion on closures, an intriguing concept in programming, and recursions, an ingenious idea to solve a plethora of programming problems.

Other courses

React

A JavaScript library to build interactive user interfaces

CSS

A language used to design web pages in countless ways