Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > PHP TUTORIALS > PHP BY EXAMPLE: PART 1


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

PHP by example: Part 1
By Erik Zoltan - 2004-06-24 Page:  1 2 3 4

Effortless Webzine authoring and delivery

As a language for building dynamic Web pages, PHP offers a implified method for constructing complex and powerful Web-related programs.Step by step, Erik demonstrates the fundamental principles of PHP in an original, real-world Web site example. Part 1 of this two-part series offers the basics of PHP and features a Webzine that includes an author's page where content providers can enter the text of articles, as well as a front end for presenting this content to the world.

If you're new to PHP, you might be pleasantly surprised by how easy it is in practice. My intention is for you to come away with a good feel for what it's like to work in PHP; after that, you can decide whether or not it's right for you.

Hands-on PHP

Part 1 of this two-part series explains how the application works (it doesn't cover the installation of PHP on your system). You'll have a chance to try out the main index page, and then take a peek under the hood to see how some of the components work. If this only whets your appetite, then be sure to check out Part 2, which goes into more detail about the rest of the main index page. (Part 2 also discusses the authoring component with a few coding examples. You can download the source code and try out your own ideas.)

If you know HTML and are familiar with any C-like language (especially Perl), then you should have no problem comprehending the following examples. Even if you haven't used a C-like language very much, you might still be able to follow the examples. But you really do need to know the rudiments of HTML.

The sample PHP application is a reader-generated Webzine with a simple delivery module (less than 3K of code). This module shows a list of topics. Under each topic heading is a series of article summaries in reverse chronological order. The user can read the full article by clicking on the title. There's also a slightly more involved authoring module (about 8K of code) that lets any reader become an author and submit his or her own content. Authors must select a category and enter an article title, a brief synopsis, and the full text of the story. Optionally, you can enter the URL of an image file and click on a "Preview" button to verify that you got it right. The author's input is validated -- it's even put through a security check that will guard against risky or malicious HTML coding practices by converting all but a few safe tags into an inactive format. For example, the string <applet would become &lt;applet. This conversion effectively disables the tag.



View PHP by example: Part 1 Discussion

Page:  1 2 3 4 Next Page: A special PHP technique

First published by IBM developerWorks


Copyright 2004-2017 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.