Step # 1 – Gear up
The very first thing that we need to have is a local server. It can be our own personal computer. We will use WAMP server to accomplish that task and turn our personal computer into a local server. WAMP stands for Windows Apache MySQL and PHP. WAMP can be downloaded and installed from wampserver.com. Material on how to install WAMP server can be easily found on the internet.
Once the download is finished and the installation is complete, we have geared up our computer to act as a local server.
Step # 2 – Setting up the test
After the install we should make sure that WAMP is running on our computer. This should be a green colored icon in the taskbar when you run WAMP. Now, we should proceed to the second phase of our code test. We need to write a simple PHP code and save it. We can write up a code to add two numbers and saving it in a PHP variable and then printing it on screen.
Once done, the file should be saved in a folder in the www directory of our WAMP server, and should be saved with a .php file extension. For ease we will name the folder as test, and the file as index.php.
Step # 3 – The test
Simple as it is, now all we need to do is use our browser to navigate to “localhost” and run PHP code on the local server. Just type “localhost” in the address bar of the browser, and it will navigate to the WAMP home. Once there, you can find the test folder and click it to run the index.php file. The WAMP server will compile and execute the PHP code and send the result to our browser. The only difference here is that the server is our own computer.
That is how we test and run PHP code before we publish it on to the internet.