Key Concepts

Review core concepts you need to learn to master this subject

Applications of PHP

PHP is a server scripting language used for making dynamic web pages. That means PHP allows you to use scripts on a web server to produce a response customized for each client’s (user’s) request.

PHP is the foundation of:

  • Many CMS (WordPress, Drupal, Joomla)
  • E-Commerce Platforms (WooCommerce, Magento)
  • Web Development Frameworks (Laravel, CakePHP, Symfony)

PHP Comments

Comments are text within code that won’t be executed when the program is run.

Comments can be useful for explaining how code is working and leaving notes for other developers. PHP supports both single line comments and multi-line comments.

For single line comments, the syntax is // or #. Anything after these symbols on a line is ignored by the PHP interpreter.

For multi-line comments, anything between /* and */ is ignored by the interpreter.

Terminating a PHP Statement

In PHP, a semicolon ; must be used to terminate a statement.

Omitting a semicolon at the end of a statement will cause PHP to assume that the next statement is part of the current one since whitespace is usually ignored. This might throw an error.

PHP Keyword Case-Insensitivity

PHP is NOT case sensitive for language keywords like if, else, null, echo, foreach, etc.

A specific example- Echo is interchangeable with echo. However, it is good practice to use the same casing from when the keyword or function was defined.

On the other hand, constants, variables, array keys, class constants and class properties are case sensitive.

PHP Script Execution

PHP can be served such that any browser making a connection to the server can execute the PHP file. This is called server-side scripting.

From the terminal, PHP scripts can be executed on demand and the output of the script is logged to the terminal. This is called command-line scripting.

PHP echo Keyword

The echo keyword in PHP is used to write output to the browser, if being served.

If it is executed in the command-line, then the echo keyword writes the output to the terminal.

Introduction to PHP
Lesson 1 of 1
  1. 1
    PHP was created in 1994 and is one of the foundational technologies of modern web development. Given all the new technologies used today, is there still a place for PHP? PHP remains one of the wid…
  2. 2
    PHP is often used to build dynamic web pages. A dynamic web page is one where each visitor to the website gets a customized page that can look different than how the site looks to another visit…
  3. 3
    In the previous exercise, we explored how PHP can be sent from the back-end to the front-end where it is received as HTML to be displayed by a browser. PHP is flexible and can also be executed fro…
  4. 4
    Sometimes, we want to include text in our files that we don’t want the computer to execute or display to the end user. We can do this with comments. Comments can be used to annotate our code to m…
  5. 5
    Before moving on, let’s take a quick look at a working PHP application. We’re going to show you an example of PHP being used on the back-end to create a dynamic website sent to the browser. When …
  6. 6
    In the next lesson, you’ll start creating your own PHP code. Take a second and review what you already know about PHP: - Despite its age, PHP is still a commonly used technology in web development….

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo