- Computers & Software»
- Computer Science & Programming»
- Programming Languages
How to test a PHP script offline
If you want to learn PHP or if you want to test a PHP script or if you want to test various designs for a PHP based website, you'll need an offline environment to simulate an online server.
There are many solutions for this, but your computer is running Windows XP, I warmly recommend XAMPP. This is a package of software containing the Apache server, PHP and MySql. Here is how you can test your PHP script.
1. Download the XAMPP package from this page. There are 3 flavors of XAMPP: installer, an ordinary ZIP file or an 7zip file. To keep it simple, download the zip file here.
2. Unzip all the files to a folder on your hard disk. The XAMPP folder can be installed on a USB device. Be careful to keep the folder structure.
3. Go into the XAMPP folder. To start the XAMPP environment double click the apache_start.bat file and the mysql_start.bat file. You may also use the xampp-control.exe file.
4. Launch your favorite browser and in the navigation window type this address: http://127.0.0.1 or this address: http://localhost.
If everything is OK, you will see the XAMPP window.
To test your script, you must create a folder for your script in c:\xampp\htdocs (if you installed on other drive/folder, change the drive letter or folder name accordingly). Supposing you want to test a script named myscript, create the folder c:\xampp\htdocs\myscript and put the files in this folder. Please note: to access your script, type this in your browser: http://127.0.0.1/myscript/.
The picture below shows a Wordpress blog installed locally on my hard disk.
All you have to do next is to edit your script the way you want. Refresh the page to see your updated script.
When you are done modifying the script, stop the Apache server and the MySql server.
Please note: working with XAMPP is a security problem, well explained at the download page mentioned above in this article. Please read carefully and make sure you are not exposed.