View Feed
group-icon
PHP Programmers
Community for PHP Programmers : Ask questions, doubts and help each other get better at PHP
297 Members
Join this group to post and comment.
Pensu
Pensu • Apr 6, 2010

How to run PHP scripts using XAMPP

I am learning PHP and oone of my has given me a software XAMPP which can run PHP scripts....but i dont know how to use it.So if anyone knows about it then plz tell me....
Kaustubh Katdare
Kaustubh Katdare • Apr 6, 2010
nicepeeyush
I am learning PHP and oone of my has given me a software XAMPP which can run PHP scripts....but i dont know how to use it.So if anyone knows about it then plz tell me....
Using XAMPP is very easy. Follow these steps -

1. Run the XAMPP application. Turn on Apache & MySQL (if your application needs database) services through it.
2. Click on 'Explore' button on the XAMPP control panel - in the window that opens, check for htdocs folder.
3. htdocs folder is the one where all your PHP scripts should lie. This is the folder that Apache points to.
4. You might want to create a separate folder inside /htdocs/ folder to save all your PHP programs. Let's call it 'myprograms'.
5. Save your php script in /htdocs/myprograms folder. (Ex. test.php)
6. Now, start your webbrowser and type following address: https://localhost/myprograms/test.php

Your browser will now execute the script and show you the output.

I hope this works for you. If you have further questions, feel free to ask πŸ˜€
Pensu
Pensu • Apr 7, 2010
Thanks Biggie...it worked....πŸ˜€
Anu18
Anu18 • Aug 15, 2011
I tried as biggie told..but im nt getting the o/p..its cming as 403 forbidden error
Pensu
Pensu • Aug 15, 2011
403 forbidden error means that accessing to the file/folder you are trying to open has been denied. Misconfigurations and bad system or/and security and firewall settings can cause this error. Check this:

HTTP Error 403 Forbidden Explained
Pensu ..thank you .. this helped me .
Rajeev NR
Rajeev NR • Mar 28, 2012
hai,... i am Rajeev from Kerala(INDIA). i am a fresher in php development. i would like to study about php language. i dont know anything about php...i installed XAMPP from net. now i am studying php tutorials...please help me, how can i run a php program ?
Kaustubh Katdare
Kaustubh Katdare • Mar 28, 2012
Rajeev NR : Read this post ->

The_Big_K
Using XAMPP is very easy. Follow these steps -

1. Run the XAMPP application. Turn on Apache & MySQL (if your application needs database) services through it.
2. Click on 'Explore' button on the XAMPP control panel - in the window that opens, check for htdocs folder.
3. htdocs folder is the one where all your PHP scripts should lie. This is the folder that Apache points to.
4. You might want to create a separate folder inside /htdocs/ folder to save all your PHP programs. Let's call it 'myprograms'.
5. Save your php script in /htdocs/myprograms folder. (Ex. test.php)
6. Now, start your webbrowser and type following address: https://localhost/myprograms/test.php

Your browser will now execute the script and show you the output.

I hope this works for you. If you have further questions, feel free to ask πŸ˜€
Abhishek Swain
Abhishek Swain • Mar 28, 2012
Rajeev NR
hai,... i am Rajeev from Kerala(INDIA). i am a fresher in php development. i would like to study about php language. i dont know anything about php...i installed XAMPP from net. now i am studying php tutorials...please help me, how can i run a php program ?
I suggest you to go for WAMP SERVER. It's hassle free !
Abhishek Swain
Abhishek Swain • Mar 28, 2012
Abhishek Swain
I suggest you to go for WAMP SERVER. It's hassle free !
As easy as 1-2-3
1) Install Wamp Server
2) Start Wamp Server using your Desktop icon.
3) Copy your project files to c:/wamp/www folder
4) Open your browser and type 127.0.0.1
5) Select your desired folder ffrom the project folders' list.

It's Done !
Kaustubh Katdare
Kaustubh Katdare • Mar 28, 2012
WAMP and XAMPP both work almost the same way. Even XAMPP is easy to use; and I've never had any problems with it. The best thing about XAMPP is that they keep their package up to date with the latest versions of the web and database servers.

It's been long time since I used XAMPP though. Not aware of the latest developments. πŸ˜€
Abhishek Swain
Abhishek Swain • Mar 28, 2012
The_Big_K
WAMP and XAMPP both work almost the same way. Even XAMPP is easy to use; and I've never had any problems with it. The best thing about XAMPP is that they keep their package up to date with the latest versions of the web and database servers.

It's been long time since I used XAMPP though. Not aware of the latest developments. πŸ˜€
Yes, even XAMPP is good. After all it depends on your choice. I have started my way with wamp server. So thought of suggesting others. 😁
Rajeev NR
Rajeev NR • Mar 30, 2012
thank you very much dear,..i will expect more helps in the future ....go may bless you
emilydecker
emilydecker • Mar 30, 2012
hey! myself emily decker from london(UK). i am a developer in php, i like this news....good one
My Blog
Programmist
Programmist • Mar 31, 2012
I don't know much about XAMPP but WAMP is way too easy to use in all ways for meπŸ˜€ .
Actually XAMPP has more configuration options and will baffle the newbies and render it difficult to run... WAMP doesn't have much options and it is easy! πŸ˜€
soumikdas22
soumikdas22 • Jun 6, 2012
sir i m having a difficulty with xampp .its showing 404 error ..
Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404

localhost
06/06/12 23:01:58
Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1



What URL did you enter? Try WAMP Server and let us know!
soumikdas22
soumikdas22 • Jun 7, 2012
Praveen-Kumar
What URL did you enter? Try WAMP Server and let us know!
i am not sure what happened yesterday.. now it is working fine..
iam12
iam12 • Jun 18, 2012
What does error 404 mean?
iam12
iam12 • Jun 18, 2012
The_Big_K
Rajeev NR : Read this post ->
epic fail always get error 404
iam12
What does error 404 mean?
The 404 or Not Found error message is a HTTP standard response code indicating that the client was able to communicate with the server, but the server could not find what was requested.
xheavenlyx
xheavenlyx • Jun 28, 2012
I have written an updated tutorial on XAMPP installation and getting started with development. It's very basic and for anyone who would stumble on this thread:

https://www.crazyengineers.com/commu...b-development-environment-for-learning.55490/
simiraj
simiraj • Jul 26, 2013
hi.. your description is very usaefull for me.,..... thank u
atulmittal0109
atulmittal0109 • Aug 10, 2013
Kaustubh Katdare
Using XAMPP is very easy. Follow these steps -

1. Run the XAMPP application. Turn on Apache & MySQL (if your application needs database) services through it.
2. Click on 'Explore' button on the XAMPP control panel - in the window that opens, check for htdocs folder.
3. htdocs folder is the one where all your PHP scripts should lie. This is the folder that Apache points to.
4. You might want to create a separate folder inside /htdocs/ folder to save all your PHP programs. Let's call it 'myprograms'.
5. Save your php script in /htdocs/myprograms folder. (Ex. test.php)
6. Now, start your webbrowser and type following address: https://localhost/myprograms/test.php

Your browser will now execute the script and show you the output.

I hope this works for you. If you have further questions, feel free to ask πŸ˜€
Hi Kaustabh,

I have tried that but when I run my file at https://localhost/myprograms/php_check.php
It is showing error as "Object not found". What may be the problem? I have followed exactly the above steps
Kaustubh Katdare
Kaustubh Katdare • Aug 10, 2013
atulmittal0109 : Several things to know -

1. Does the file exist at /myprograms/ folder (physically) . That is check the htdocs folder and then go to 'myprograms' folder inside it and see if the file's there.

2. Is php_check.php error free?

3. Do other files in your document root work fine?
atulmittal0109
atulmittal0109 • Aug 10, 2013
Look, I installed the Xampp server and when installed, I started the control panel. After that, I turn on the Apache ans MySQL(though MySQL is not working for some reason). Now, I clicked on the explorer and in htdocs folder, I created a folder named as "myprograms" and then I created a file with name "php_check.php" in this folder. The code written in the file is as below:
(

PHP Check File

print "

Congratulations, your server can process PHP!

";
print "

Here you can view the PHP configuration on your server

";
phpinfo( );
exit();
?>

Sorry, PHP is not enabled on this server.




Check your host provider documentation or contact
your host provider to ask them how to enable PHP.




)

Now, when I type the address in my browser as https://localhost/myprograms/php_check.php
it is still showing the same "object not found error"
atulmittal0109
atulmittal0109 • Aug 10, 2013
Hi,

I have got the solution. There was something wrong with the file extension. Thanks for your time and help.
Kaustubh Katdare
Kaustubh Katdare • Aug 10, 2013
You don't need to put that file in the myprograms folder. If you just want to test whether XAMPP is working or not, you can put that file directly in htdocs folder and then access it from https://localhost/php_check.php . Also check if your browser can render any text file if you put it in htdocs folder and access it from https://localhost/.

If that doesn't work - your setup may have issues. Check whether XAMPP\apache\conf\httpd.conf is pointing to the right directory. Look for something that says "DocumentRoot".
atulmittal0109
atulmittal0109 • Aug 10, 2013
Its working fine now both with php and text files. Thanks
Nayan Goenka
Nayan Goenka • Aug 10, 2013
If you get struck at some errors and you think Xampp is working fine, try check your code for some missing tags. I had a recent experience when I screwed up some tags in the code that lead to malfunction. It was a stupid mistake and it was fixed easily but i had to waste a lot of time in to it.
I am also getting the same error 404.I entered url https://localhost/myprograms/test.php
Folder myprograms is saved in htdocs and test.php in myprograms.
please help me otherwise i will not even be able to start using php.
Kaustubh Katdare
Kaustubh Katdare • Nov 10, 2013
@Tushar Kathuria - welcome to CrazyEngineers. Every setup is different; so we need to know what you've on your machine so that we can provide possible solutions.

You should perform quick checks-
  • Is your default XAMPP page loading fine?
  • If you put any text file say test.txt in /htdocs/ are you able to view it in browser by typing https://localhost/test.txt ?
Are you able to load other files in the same directory or in htdocs?
Tushar Kathuria
I am also getting the same error 404.I entered url https://localhost/myprograms/test.php
Folder myprograms is saved in htdocs and test.php in myprograms.
please help me otherwise i will not even be able to start using php.
Are you working on linux? on linux paths are case sensitive, so make sure directory name is exactly same as you are accessing on browser
NIRAJ PANDEY
NIRAJ PANDEY • Apr 8, 2014
I installed xampp on ma lappy..m newbie in php development..i tried to run php sript..bt browser dnt pops anythng inside php code...help
Ankita Katdare
Ankita Katdare • Apr 8, 2014
NIRAJ PANDEY
I installed xampp on ma lappy..m newbie in php development..i tried to run php sript..bt browser dnt pops anythng inside php code...help
Share the exact steps you performed. That will help us know what went wrong. We will guide you from there.
NIRAJ PANDEY
NIRAJ PANDEY • Apr 8, 2014
apache is running..


My first php





Dis is the script which i saved as test.php inside xampp\htdocs\nirajphp folder..
Then i opened chrome and typed https://localhost/nirajphp/test.php
title is displayed bt nothing is echoed..
Ankita Katdare
Ankita Katdare • Apr 8, 2014
@NIRAJ PANDEY

To echo something, you can just write this code inside the test.php file.

echo "Hello World";
?>

That should work. πŸ‘
NIRAJ PANDEY
NIRAJ PANDEY • Apr 8, 2014
tht worked thanxx..!! plzz cn u explain wat ws wrng in my code?
Manish Goyal
Manish Goyal • Apr 8, 2014
you were using short code which might have disabled in your php.ini settings

For more info
https://www.php.net/manual/en/language.basic-syntax.phptags.php

Share this content on your social channels -