# Introduction PHP

# 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
  • We use the 8.1.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://pverhaert.sinners.be/hello_world.php (opens new window)
  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
  4. The result (plain HTML) is sent to the client's browser

# 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 (opens new window)), 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: 12/8/2021, 8:00:21 AM