Now that you know how to use XAMPP Lite, it’s time to write your first PHP script.
This tutorial will guide you on writing your first PHP script, show you how the PHP syntax is used, and where to put and run your PHP pages in XAMPP.
Note: this tutorial assumes you are using XAMPP Lite environment for your PHP scripts. If you want to setup your own XAMPP Lite environment, follow this tutorial about installing XAMPP Lite on a portable device.
Finding your Web Directory
Before you start writing, you need to locate your web directory. This is a special directory within your web server (in our case XAMPP Lite) where all the webpages are located.
When you type a URL into your browser, you are requesting for a file. This file has to be located within the web directory for the web server to deliver it to you. As such, if you have a PHP script, you need to put it into this web directory in order for it to be available to be browsed by your browser.
In our installation of XAMPP Lite, go to the your XAMPP Lite install directory. In that directory, you should see a folder called ‘htdocs’. This is your web directory.
Open this directory, and you should see something like this, with some images files, a couple of folders, some image files, one HTML file and one PHP file. For the moment, just ignore them.
Create your PHP file
The next thing you need to do is to create a file within this web directory. So go ahead an do that, and name the file ‘hello.php’, and put the following source codes into the page.
My First PHP Page