w1coding.comAll tutorials

PHP Environment Setup

PHP lessons
  1. Environment Setup
  2. Introduction
  3. Variables
  4. Basics
  5. Operators
  6. Control
  7. Loops
  8. Variables
  9. Functions
  10. Arrays
  11. Superglobal
  12. File
  13. Loops
  14. Date
  15. Loops
  16. Strings
  17. Error
  18. Class
  19. File
  20. Include
  21. Sessions
  22. Mysql
  23. Cookies
  24. Forms
  25. Cookies
  26. Regular
  27. Authenthication
  28. Fileupload
  29. Mvc
  30. Responsive

PHP executes on a server or in a terminal. Opening a PHP file directly in a browser does not execute its PHP code. Use the built-in server for local practice.

What you need

  • A supported PHP command-line installation
  • A code editor and terminal
  • A browser

Set up your environment

  1. Follow the PHP installation instructions for your operating system and ensure the PHP executable is available in your terminal.
  2. Run php --version. Create a folder named php-practice and save the example as index.php.
  3. Open a terminal in that folder and start the local server with the command below.
  4. Visit http://127.0.0.1:8000/. Keep the terminal open while using the server and stop it with Ctrl+C.

Your first check

Save as index.php

<?php
$message = 'Hello from w1coding.com';
echo '<h1>' . htmlspecialchars($message, ENT_QUOTES, 'UTF-8') . '</h1>';

Run or verify

php -S 127.0.0.1:8000

Expected result: The browser displays Hello from w1coding.com as a heading.

Common setup problems

  • If the port is occupied, use another local port, such as 8001, in both the command and browser address.
  • The built-in server is for development. Do not expose it as a public production server.

Official documentation

Guide reviewed 17 November 2026. Check the linked vendor documentation for current supported versions and operating systems.