HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [194]
Java
Java has been a strong contender for a long time now. The language is indeed named after coffee. If you work for a banking company or insurance company, or need to build the next eBay or Amazon.com, you might want to consider using Java. However, Java can consume a lot of time, and it’s hard to figure out. You may have to write up to 16 lines of code to do in Java what could take a mere 4 lines of code in PHP. Java is absolutely free, as is the Apache Tomcat Web server that it uses to serve its Web components. Java was originally created to write desktop applications and is still very good at doing that. If you’re comfortable with C/C++, you’ll be very comfortable with Java because it’s very similar. It’s fully object-oriented, and it’s compiled. Java is powerful, but it can be challenging for beginners. It’d be a great second language to work with.
PHP
PHP was born from a collection of modifications for Perl and has boomed ever since (in a way, replacing Perl, which was once considered the duct tape and bubble gum that held the Internet together).
Compile versus interpret?
What’s the difference between an interpreted language and a compiled language? A compiled language is compiled one time into a more computer-friendly format for faster processing when called by the computer. Compiled languages are typically very fast but not very flexible. Interpreted languages have to be interpreted on the spot by the server every time they’re called, which is slower but provides more flexibility. With blazing fast servers these days, interpreted languages can normally stand under the load, and the ability to handle changes without recompiling can be an advantage in the fast-paced world of Web development.
PHP works great for your server-side Web development purposes. MediaWiki (the engine that was written to run the popular Internet encyclopedia Wikipedia) runs on PHP, as do many other popular large-, medium-, and small-scale Web sites. PHP is a solid, easy-to-learn, well-established language (it’s 13 years old). PHP can be object-oriented or procedural (you can take your pick!). PHP is interpreted rather than compiled.
Installing Your Web Server
For PHP to work usefully, you have to have some other things installed on your computer, such as
♦ A Web server: This special program enables a computer to process files and send them to Web browsers. I use Apache because it’s free and powerful, and works very well with PHP.
♦ A database backend: Modern Web sites rely heavily on data, so a program that can manage your data needs is very important. I use MySQL (a free and powerful tool) for this. Book VI is entirely dedicated to creating data with MySQL and some related tools.
♦ A programming language: Server-side programming relies on a language. I use PHP because it works great, and it’s free.
There are two main ways to work with a Web server:
♦ Install your own, using the free XAMPP software. Download from www.apachefriends.org/en/xampp.html. Book VIII, Chapter 1 has complete instructions on installing XAMPP.
♦ Work on a remote server that somebody has already set up. Freehostia (www.freehostia.com) is one example that has everything you need for free.
Please check out Book VIII, Chapter 1 for complete information on both techniques. After you have your machine set up or you have an account somewhere with PHP access, come back here. I’ll wait.
Inspecting phpinfo()
Using your shiny new server is really quite simple, but a lot of beginners can get confused at this point.
One thing you have to remember is that anything you want the server to serve must be located in the server’s file structure. If you have a PHP file on your Desktop