Building a Dynamic Website with PHP

PHP stands for "PHP: Hypertext Preprocessor" (formally known as Personal Home Page). It is one of the most useful and powerful tools for creating dynamic and interactive Web pages. It is widely-used, free, and an efficient alternative to competitors such as Microsoft's ASP and other scripting languages. Facebook was mostly coded using PHP (along with the help of database management system Mysql). PHP supports many databases (MySQL, Oracle, PostgreSQL, etc.). You can create an entire search engine for a website using PHP. The possibilities are endless.

PHP is a server-side scripting language, like Ruby on Rails, ASP, JSP and others. That is, PHP code is interpreted, run, and compiled by the server it is on. Scripting and markup languages such as Javascript and HTML, on the other hand, are executed by a browser. Understand the difference? Good.

When PHP code is compiled and run, it results in HTML. This HTML is then sent to the browser that is requesting a web page. PHP is extremely useful for creating dynamic web pages. The content of these pages can constantly change depending on what information the PHP code is given. This is done by means of variables and functions (which you are familiar with from other programming language). Let's set up our PHP environments and start coding!

Installing a Server Environment

If you use the environment available on csdb.csc.villanova.edu, then you won't need to install anything! It includes everything we need to develop dynamic webpages -- PHP, an Apache web server and MySQL database server. Follow these instructions to test the PHP environment on csdb.

If you use your own computer for developing dynamic websites (the database project in particular), then you'll most likely need to download a complete server environment. Most computers don't come with PHP installed. An exception is Mac OS, but you'll still want to install a server environment even if you are on a Mac.

There is a large number of these environment packages available. For a testing server that simulates a real world Web server, XAMPP is the perfect choice. It lets you create databases, build dynamic Web pages, and view them right on your own computer making it easier for you to build and test database-driven Web sites. XAMPP is essentially an Apache Web server, PHP, MySQL database server, and other software rolled up into a single package that you can install on your computer.

(Note: You may also use MAMP if you are on a Mac, and WAMP if you are on Windows, but here we provide instructions for XAMPP only.)

Download and Install XAMPP on Windows

Download and Install XAMPP on Mac