Introduction

About PHP

  • PHP is a popular server-side scripting language especially suited to web development
    • PHP scripts are executed on a web server, in contrast to client-side scripting languages as JavaScript, jQuery, ...
  • PHP runs on multiple platforms (Linux, Windows, macOS) and is supported by most web server technologies (Apache, Nginx, IIS)
  • PHP is free to use and to host
  • A lot of software is written in PHP like Joomla, Drupal, Magento, ...
  • There are lots of available PHP frameworks like Symfony, Laravel, Zend, CodeIgniter, ...
  • PHP was originally created by Rasmus Lerdorf in 1994 and stood for "Personal Home Page". Nowadays it's a (recursive) acronym for "PHP: Hypertext Preprocessor".
  • PHP syntax has a lot of similarities with the C style (C, C#, Java, JavaScript, ...) syntax
  • Current stable version: 8.0.10 (but we use the 7.4.x version in this course; see Config > Work environment)

How does it work

How does PHP work?
  1. A client calls a PHP page (containing HTML and PHP scripts) in his browser: https://jkwadraat.sinners.be/hello_world.php
  2. The client's browser contacts the web server
  3. The web server executes the PHP scripts in hello_world.php (and communicates with the database if necessary), and translates them to HTML code








 



<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello world</title>
</head>
<body>
<h1><?php echo 'Hello world'; ?></h1>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
  1. The result (plain HTML) is sent to the client's browser








 



<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello world</title>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11

A local webserver

  • During development, it's easier to work with a local webserver (in order to avoid uploading files after every change)
  • Most popular are the so-called XAMP implementations (for example Ampps), where
    • X stands for W(indows) -> WAMP, L(inux) -> LAMP or M(acOS) -> MAMP
    • A stands for Apache
    • M stands for MySQL
    • P stands for PHP
  • In this course, we will use Homestead, which is a virtual web server environment (including Nginx, MySQL, PHP, ...) that runs on Windows, Linux and MacOS
    • Part of Laravel, but can be used for classic PHP web applications as well
Last Updated: 9/16/2021, 3:56:42 PM