If you are going to learn to code with PHP for the web, you will eventually need to set up a development (“dev”) machine. This means configuring a web server like Apache HTTP Server along with PHP. If you want to complete the exercise without having a dev box set up, head over to the fabulous online W3C PHP Compiler: W3Schools Tryit Editor.

1. Just another text file

Create a PHP file. PHP files are text files with the .php extension. You can code using any text editor, Notepad, Notepad++, or VSCode. For your first steps, you may find the process easier to follow using just Notepad.

Create a file called index.php and open it in your code editor.

Enter the following code (line-by-line explanations follow):

    echo 'Hello World!';
  1. All your PHP code will start with <?php
  2. echo is a PHP function that outputs a text string; the text string is between quotes, in this instance, Hello World!
  3. your PHP code ends with ?>

Save your file and open the index.php file in your browser (the file can be open in your text editor and your browser at the same time).

2. Add some HTML

Bored already? Well, how about combining your HTML skills with your new PHP skills:

    echo '<h1>Hello World!</h1>';


  1. W3Schools online PHP editor (no date) W3Schools Online Web Tutorials. Available at: https://www.w3schools.com/php/phptryit.asp?filename=tryphp_compiler (Accessed: 25 November 2023).
  2. Wikipedia contributors. (2023, November 25). PHP. In Wikipedia, The Free Encyclopedia. Retrieved 18:20, November 25, 2023, from https://en.wikipedia.org/w/index.php?title=PHP&oldid=1186790181
  3. Buckler, C. (2022) How to install PHP on Windows 10 and 11 (with Apache & MySQL), SitePoint. Available at: https://www.sitepoint.com/how-to-install-php-on-windows/ (Accessed: 08 January 2024).

By MisterFoxOnline

Mister Fox AKA @MisterFoxOnline is an ICT, IT and CAT Teacher. He has a passion for technology and loves to find solutions to problems using the skills he has learned in the course of his IT career.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.