Section 1.1. PHP and MySQL s Place in Web Development


1.1. PHP and MySQL's Place in Web Development

PHP is a programming language designed to generate web pages interactively on the computer serving them, called a web server . Unlike HTML, where the web browser uses tags and markup to generate a page, PHP code runs between the requested page and the web server, adding to and changing the basic HTML output. For example, PHP code could be used to display a counter of visitors to a site.

PHP, in less than 20 lines of code, can store the IP address from which a page request comes in a separate file, and then display the number of unique IP addresses that visited a particular site. The person requesting the web page doesn't know that PHP generated the page, because the counter text is part of the standard HTML markup language that the PHP code generated.

PHP makes web development easy, because all the code you need is contained within the PHP framework. This means that there's no reason for you to reinvent the wheel each time you sit down to develop a PHP program; that would be something you'd have to do if you were using a compiled language like C.

While PHP is great for developing web functionality, it is not a database. The database of choice for PHP developers is MySQL, which acts like a filing clerk for PHP-processed user information. MySQL automates the most common tasks related to storing and retrieving specific user information based on your supplied criteria.

Take our Amazon example; the recommendations Amazon offers you can be stored in a MySQL database, along with your prior order information.


MySQL is easily accessed from PHP, and they're commonly used together as they work well hand in hand. An added benefit is that PHP and MySQL run on various computer types and operating systems, including Mac OS X, Windows-based PCs, and Linux.

1.1.1. Advantages of Using PHP with MySQL

There are several factors that make using PHP and MySQL together a natural choice:


PHP and MySQL work well together

PHP and MySQL have been developed with each other in mind, so they are easy to use together. The programming interfaces between them are logically paired up. Working together wasn't an afterthought when the developers created the PHP and MySQL interfaces.


PHP and MySQL have open source power

As they are both open source projects, PHP and MySQL can both be used for free. MySQL client libraries are no longer bundled with PHP. Advanced users have the ability to make changes to the source code, and therefore, change the way the language and programs work.


PHP and MySQL have community support

There are active communities on the Web in which you can participate and they'll answer your questions. You can also purchase professional support for MySQL if you need it.


PHP and MySQL are fast

Their simplicity and efficient design enables faster processing.


PHP and MySQL don't bog you down with unnecessary details.

You don't need to know all of the low-level details of how the PHP language interfaces with the MySQL database, as there is a standard interface for calling MySQL procedures from PHP. Online APIs at http://www.php.net offer an unlimited resource.

1.1.2. The Value of Open Source

As we mentioned above, both PHP and MySQL are open source projects, so there's no need to worry about user licenses for every computer in your office or home. In open source projects and technologies, programmers have access to the source code; this enables individual or group analysis to identify potentially problematic code, test, debug, and offer changes as well as additions to that code. For example, Unixthe forerunner in the open source software communitywas freely shared with university software researchers. Linux, the free alternative to Unix, is a direct result of their efforts and the open source licensing paradigm.

As Tim O'Reilly puts it, "Open source licensing began as an attempt to preserve a culture of sharing, and only later led to an expanded awareness of the value of that sharing." Today, open source programmers share their code changes on the Web via php.net, listservs, and web sites. If you're caught in a coding nightmare and can't wake up, the resources mentioned above can and will help you.

We'll arm you with open source user forums later in this book so you can check them out yourself. We'll include listservs and web sites so that you have numerous resources if you run into a snafu.




Learning PHP and MySQL
Learning PHP and MySQL
ISBN: 0596101104
EAN: 2147483647
Year: N/A
Pages: 135

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net