View Full Version : PHP basics
Illera 05-12-2006, 09:21 PM I want to make an archive of sorts, but I don't want to publish it to the web (you know how you can open up websites that you're working on in a browser, if you saved the files as htm, even when you're not connected to the net?). I just want it on my computer. So it would need to open in a browser, even if the files were just in my 'My Documents' folder and not uploaded to a website.
In this archive, I want to be able to search by different categories, like this (http://www.tillerwebdesign.com/efiction/search.php)or this (http://www.fanfiction.net/search.php). Pretty simple would be nice; I only really need the dropdown elements to the search engine.
I gather I need to work in php to do this, and so I started searching for free php scripts to study, namely search engine scripts, and found quite a few. But when I downloaded them, I couldn't work with them. They don't open as websites. I'm incredibly confused. Is there a really good place to go to learn the basics of php?
I've never worked with php before and I don't have the slightest clue what I'm doing. Any help would be very appreciated.
Raphael 05-12-2006, 10:16 PM *grins* ..
Well, welcome to the wonderful world of PHP programming. I hope you're ready for the can of worms you just opened.... ;)
Unlike HTML, PHP is a programming language. HTML and CSS are markup languages. They delineate sections of text in a web page, and describe how those sections look. They don't "run" or "execute" and they don't really provide any interactivity with the user.
PHP, however, is an executable programming language, like C, Java, COBOL or any of those other languages you may or may not have heard.
What this means is that you need something that knows how to process the PHP commands. Unfortunately, your web browser isn't able to do this. It can only read and display HTML, and the only real programming language it understands is Javascript.
The problem, you see, is that there is no interface between your pages and your web browser. Normally, on a website such as LEIA, a webserver sits between the page and the browser. This webserver (more or less) interprets the PHP and ensures that all that the browser actually sees is the HTML output of the PHP program.
By simply opening up a php file from Windows explorer in your web browser, you're skipping that step, and your browser is faced with a bunch of code that it doesn't know what to do with.
The long and the short of all of this is that if you want to view PHP files on your local machine at home, you need to set up a webserver and configure it to understand PHP, all on your home machine.
Starting off in PHP by yourself can be very daunting, because there are a lot of things to learn at the same time:
1. How to install a web server
2. How to install PHP
3. How to get the web server to use PHP to process PHP pages
4. The interaction between web browsers and web servers.
If I haven't scared you off, and you'd still like to know more, I'd be happy to continue....
sunshinemom 05-12-2006, 10:55 PM I hope you don't mind me piggy backing off of your reply with a question of my own.
Do you still have to install the web server, and PHP if your hosting offers (apache and PHP) it?
Illera 05-12-2006, 11:47 PM ...well this looks like it will be fun. : ) Wow.
Wow. Okay, I think that made sense. HTML and CSS show you things, and PHP (and Java, which I do have some limited experience with) does things for you before it shows you things. And I need a server to interpret the commands in a php script.
How can you have a server on just one computer, though? I thought servers supported a lot of websites. And is this something that can be done for free? And what do you mean, install PHP? Is that like frontpage or notepad?
I'd love to learn more - keep going! Thank you so much.
Raphael 05-17-2006, 09:52 PM I hope you don't mind me piggy backing off of your reply with a question of my own.
Do you still have to install the web server, and PHP if your hosting offers (apache and PHP) it?
No, you don't - Although you'll have to install it at home if you want to test your pages before uploading them to the server. (See my reply to your other thread for more information about why this needs to happen) :)
Raphael 05-17-2006, 10:01 PM ...well this looks like it will be fun. : ) Wow.
Wow. Okay, I think that made sense. HTML and CSS show you things, and PHP (and Java, which I do have some limited experience with) does things for you before it shows you things. And I need a server to interpret the commands in a php script.
How can you have a server on just one computer, though? I thought servers supported a lot of websites. And is this something that can be done for free? And what do you mean, install PHP? Is that like frontpage or notepad?
I'd love to learn more - keep going! Thank you so much.
*takes deep breath*
Okay..
There's a little bit of confusion with terminology here. In fact, there has been ever since I started in this business back in '92.
Officially a server is a computer. A single physical machine. The word 'server', however gets used a lot to represent a program that serves data running continuously on a computer. In absolutely precise terms, that's actually called a daemon. (Pronounce it like demon)
Examples of things that people call web servers would be: apache, OmniHTTPd, Microsoft's IIS, and others. The 'd' in OmniHTTPd by the way, stands for daemon ;)
A web server (or web daemon) is a program that continuously runs and waits for requests for web pages. When it receives a request, it creates a copy of itself (that's called forking) to handle that request and the copy goes and gets that page and delivers it to the client that requested it.
Web servers can handle many requests at the same time, depending on computer speed and power, but also they can just serve a single web site and deal with 1 page request every 10 minutes. They don't really care.
When you're looking to test your PHP-enabled web pages on your local home machine you basically have to create an identical setup to the way your hosting company has their server set up..... However, before anyone runs screaming in terror saying 'I didn't get into this game to be a sysadmin', remember that it doesn't have to be nearly as complex, because you're not serving potentially millions of pages a second to thousands of users. Just you. :)
However, you *do* have to have the essentials. A web server, and an interpreter for your scripting language of choice.
But.. If this all seems like entirely too much work, just go ahead and write the pages and test 'em when you upload - The hosting company has already got its servers configured to understand PHP code.
But if you really do want to know what's involved in getting a setup on your local machine that will understand your PHP, let me know and I'll continue......
Raphael 05-17-2006, 10:28 PM And is this something that can be done for free? And what do you mean, install PHP? Is that like frontpage or notepad?
I'd love to learn more - keep going! Thank you so much.
Oops, i forgot to answer the rest of this, sorry.
1. Yes, you can do it for free. The most popular web server on the internet, apache, is available for free download and use, and PHP is also free to download and use.
2. Installing PHP like frontpage or notepad? Err, sort of. You can think of PHP as an application like Frontpage or Word that only your web server (once you install one) can access. Instead of having an icon to click on that starts "the program" for you to see on your desktop, it just sits inside your computer and waits for your web server to tell it to do something.
Install XAMPP; it does all the hard work for you all you need to do is run files on localhost. Although it is a very power sucking program, so only use it's full features when you need 'em.
http://www.apachefriends.org/en/xampp.html
|