How to run your first PHP CODE
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 starters to install these bundles separately and combine them to run PHP. XAMPP does that for you with just a few clicks.
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 need to 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 is C:\xampp\), then go to "htdocs" folder (default is C:\xampp\htdocs\)
All your php files has to be in this \htdocs\ folder. This is called web server's root. 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 that, when you save the file using a text editor, place double quote around the file name: e.g. "test.php"
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 after 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: http://localhost/test.php
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
by Fayaz Ahmed
Leave a Reply
Jan 7th 2011 • 00:01
- samir
Thanks for the information. I wanted to start web development using PHP.
But, It gave me a headache when I tried to install Apache, PHP and MySQL all together. Also, I heard sometimes you need the matching versions of those software to work together properly.
XAMPP saved the day! Now I can easily follow web development tutorials in my off time.
Aug 16th 2011 • 23:08
- Bona
Thx. Is working proerly
Oct 6th 2011 • 10:10
- Md.Shazid hasan
this Helps a lot for a newcomer; like it
thanks
Feb 19th 2012 • 00:02
- krishna
its working thanks
Mar 6th 2012 • 00:03
- pratik
thanks it is working!!!!!!!!!!
Mar 24th 2012 • 16:03
- sagar
thanks
Mar 26th 2012 • 10:03
- Singh & Brothers
thanx it working properly
Mar 26th 2012 • 23:03
- soni
thanks..........
Apr 11th 2012 • 15:04
- Azhar
Hi Fayaz, it's working great, waiting for your next update.
May 28th 2012 • 22:05
- shaikh alam dumaria
thanx realy it work properly
May 28th 2012 • 22:05
- shaikh alam dumaria
i am working now on xampp wap server sql database, and i am tring to rum php code in xamp but i can't find place to coding php script and run.please help me anyone.
thanks
May 28th 2012 • 23:05
- Fayaz Ahmed
Are you looking for this: http://www.apachefriends.org/f/viewtopic.php?p=154027
Aug 17th 2012 • 12:08
- rohti
thnx its working....
Jun 11th 2012 • 20:06
- Amutha Babu
Thank u very much for the support
It is very useful to newly learning people
Jun 29th 2012 • 11:06
- hema
thnx 4 info
Aug 14th 2012 • 00:08
- saikat sarkar
thanks. it's really helpful
Aug 30th 2012 • 13:08
- jyoti
Thanx.It is working.