Jump to content

Making a .php file


porzant
 Share

Recommended Posts

This question probably sounds stupid, but how do I make a .php file and use it. I've saved:

<?phpecho "Hello World";?>

in a HTML file like it shows you on the tutorial, but do I need to download something for it to work?Thanks for any help.I'm using Windows XP by the way.

Link to comment
Share on other sites

Hi!You need a server-software to run the script, either you have a host where you can put your work and test it, or you need a server on your computer.One of the best server-softwares is Apache it works on many platforms and does it well.The easiest way to get apache and PHP to work in Win (it's helpfull in other OSs too..) is to use XAMPP. With XAMPP you get both apache, PHP and MySQL, and it shouldn't be to hard to install.Good Luck and Don't Panic!

Link to comment
Share on other sites

i will tell u how to do that in my wayi work in windows environmentfirst of all u should install IIS on ur windowsthen install php from this link php.netsave ur (.php) file in the innetbup/wwwroot folderthen call ur own server through this url http://localhost or http://127.0.0.1and add the php file name containing the folder name if u put it in a folderex: http://127.0.0.1/my_php_work/my_first_php_file.phpregards

Link to comment
Share on other sites

That's one way to do it. But with XAMPP you get it all in one package, everything is configured to work with eachother from the beginning, no need to instal multiple packages and headakes when trying to configure them to work together...And then you ofcourse get a superior server-software ;?)I'm not a big fan of M$ work (can you tell??), much bugs and such (read about a new bug Vista today...) and what I can remember from IIS (a few years ago) is that I simply didn't like it and that there wasn't to much "good help" (forums and such) to find, Who knows, this may have changed.But one thing I'm sure of is that apache is one of the best (the best??) server softwares outhere, it's free, it's well written (as all softwares it has it's bugs, but there's almost allways someone that has expiierenced the same and are willing to help), a good (and big) community etc Oh did I say this? It's FREE... What more do you need ;?)Ok, one bad thing whith Apache may be that it can be tricky to configure as you want it, it's not impossible, just a bit tricky (I'm having some conf troubles whith my serve, but it should be fine after my next xhange..)Well, alot of "propaganda", and remembe this is my own personal thoughts.... :?)I hope we can welcome a new member to the Apache and/"or" the OpenSource community... :?) :) :)

Link to comment
Share on other sites

You'll also need to change the extension from ".html" to ".php" .. you can do that in explorer by right clicking on the file and going to rename (provided you have "view known file extensions" ticked in explorer options) or when in notepad (or something) when you save, put quotes around the filename; e.g. - "file.php".Then just follow what the others have said about running the PHP file.

Link to comment
Share on other sites

Can you please describe what problems you're having? Such as any error messages or logs that is displayed for you.Note that it can be a bit tricky to get IIS to work with PHP....

Link to comment
Share on other sites

Guest FirefoxRocks

Are you just developing in PHP and playing around? Or are you going to do entire websites in PHP?---For development purposes, you can use Apache and PHP as suggested or XAMPP. Install Apache on your own computer and then download PHP and configure it. I don't know much about XAMPP so I can't help with that, sorry. I can't get PHP working in Apache either :)A note about installing a server on your own computer:If the computer that you install the server on doesn't have Internet access, that's fine. However if you are using your main computer to install the server on then there are 2 things you NEED to know.1. SecurityInstalling a server on your own computer opens port #80 which is quite risky. Major security threats allow malicious people to access your personal documents and such. This is quite unlikely however it can still happen so be careful.2. Your ISP's terms of use.Installing a server on your own computer may violate your ISP's terms and conditions. You may get your Internet cut off because they detect traffic on port #80 (and other means as well) or your account can be automatically upgraded to a Business/Enterprise account (which can be 3x or more your residential internet). Before trying this reread your ISP's customer TOS/TaC/user agreement and contact them if necessary.I use a server on my older computer which doesn't have Internet access to it, so I should be safe.---For actual hosting of PHP sites, I highly recommend Astahost. They have a very, very wide community of helpful members that are very friendly and can help with many technical problems. They are free, the only thing you need to do to keep your hosting account running is to post on their forums to keep credits. They also have a MySQL/PostgreSQL server, 100 email accounts and many, many more features (which you may or may not use :))---Remember to save your PHP files as .php, .php3 or .phtml. .php is recommended and is most compatible. It takes time to learn PHP.

Link to comment
Share on other sites

What FirefoxRocks says is true. But both issues could be solved with one solution: a firewall.When you use a firewall you can stop any traffic in to your (I know that most users have a firewall, at least in their router or modem). I would recommend ZoneAlarm (DON'T use windows internal firewall). A firewall stops all incomming traffic so your ISP shouldn't find out that you have a server ;?) and it shouldn't mather if you have sserver, just don't have it "public"...

Link to comment
Share on other sites

When I'm downloading the XAMPP, it saves as a .biz file, which my computer can't read. Also, if a save a text file as .php, it stays as a text file. Would uploading this to FreeWebs or something make it work?

Link to comment
Share on other sites

Then you have a problem with your system, it's an exe and should be saved as an exe, either rename the file with a correct .exe extension or downoad it again and make sure you save it as an .exe.A php-file IS a textfile, but with a .php extension, the default is for notepad (or your default text-editor) to open it, if you don't install a software (editor) that opens the php-file (UltraEdit would be a good choice for example, any-one with a good syntax-highlighting should work ok)To upload the file to a host can be an idea, but it usally not recommended when you are developing. Unless you can edit it via FTP (UltraEdit among others have support for this), one problem with that is also the speed of your connection (right now I have 0.5Mb/s, and I feel some frustration when editing files via ftp...)Good Luck and Don't Panic!

Link to comment
Share on other sites

For the Page to download XAMPP for windows: Click hereForm that page i have given you should be able to download the program if you can't i'll send you the one i used.When installing unplugged your internet connection. and any network connection and open certain ports ( not sure which onces but it will tell you)From their you should remeber where u installed XAMPP from here you can then begin to make php scripts Putting them in the folder C:/Program Files/XAMPP/htdocs/ or in folders in more folders. from their you must start your internet broswer and type127.0.0.1/(where your files is located after htdocs)then you should be able to run php filesif you file is located in this locationC:/Program Files/XAMPP/htdocs/folder1and your files is called index.phptype into firefox/Internet explorer127.0.0.1/folder1/index.phpor localhost/folder1/index.phpif you need anymore help just respond i will check back.-JohnnyWelcome Aboard :)

Link to comment
Share on other sites

Make sure that xampp is running, not sure on how (maybe the "task list" Ctrl+Alt+Del, look for xampp or apache)Do you have Google Dekstop toolbar (or what it's called)? It may have taken port 80 so that xampp can't listen on it.Kill google desktop (or uninstall it...) and restart xampp.Can't think of anymore right now (also check your firewall...)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...