Few beginners asked me this question, so here is the answer (I'll update this post from time to time to meet the visitors' interests):
The easiest way to start with PHP is using XAMPP
You don't have to install Apache and MySQL separately, in fact, it is often difficult for beginners to install these bundles separately and combine them to run PHP. XAMPP does that for you with just a few clicks.
In Windows, before you install XAMPP, you'll have to uninstall existing Apache and MySQL installation (if they were installed as a service). If they were not installed as a service, then you may or may not uninstall them, it's up to you (and may be up to some unforeseen setting in your system).
After you install XAMPP, Go to the XAMPP installation folder (default in Windows is
C:\xampp), then go to "htdocs" folder (default is
All your php files has to be in this
htdocs folder. This is called web server's
root directory. So, in this folder, create a sample file, say
test.php. Also, when you make this file, make sure it has no
.txt extension at the end. Since, some text editors place
.txt at the end of file name, so it becomes
test.php.txt instead of
test.php. To avoid this, when you save the file using a text editor, place double quote around the file name: e.g.
Write the following test code in this file (using any text editor) and save the file:
<?PHP echo 'PHP is working! <br />'; ?> This is a test file.
Then, go to XAMPP installation folder (typically,
C:\xampp) and run
xampp-control.exe by double clicking it (if your OS hides file extension, then you'll see it as
xampp-control, no .exe at the end). In the appearing window, click the start button beside Apache. Later, if you need other options like MySQL, you'll also have to start MySQL by clicking the start button beside MySQL in the XAMPP control Panel.
Now, in your web browser's address bar, type the address:
If your test PHP file is working properly, then you should see the following two lines in your browser:
PHP is working!
This is a test file.
If PHP is not working, then only this one line will appear:
This is a test file.
If none of the above is happening, then you are doing something wrong somewhere else. Happy Coding