In the previous two articles we discussed how to read
and build an RSS document with PHP. In this article we will create an
application that uses the concepts discussed in the other two articles.
So let
The Application
The
layout of the application is going to be very simple: A navigation bar
on the left and a display area in the center. The display area is were
we are going to display all the output of the code. I've not used any
CSS in this application. I've instead opted to use HTML formatting to
keep things simple.
As for the actual functioning of the
application, we are going to use only one page to execute all the code.
This is because it reduces the amount of processing power required to
run the application. As a result, it makes program execution faster and
reduces coding time.
We are also going to create a few
functions that will help us to run the script. The functions are
stored in a script called "functions.php" and need to be included in
the page. In addition to the functions page, we will also need to
include the xmlparser.php page, as this will help fulfill one of the
core aims of the application.
When a user clicks on a
link, that link will send an action variable to the page. The action
variable will then be caught by the switch statement, which will in
turn process it and compare its value against the conditions set within
the case statements of the switch structure. This comparison, if
matched, will activate the appropriate function which will use the
display area to output the result. The aim of the application is to:
- Read an RSS document
- Create an RSS document
The
second link called "Create an RSS link" is more complicated to
implement than the Read RSS document link. This is because there are
two different versions of an RSS document and the application has to
decide which path to take based on the selection that the user made.
Various functions will display various forms to take input and will
create an RSS document based on the input.
All new RSS documents that
are created by this application will be stored in the same directory
where the application resides. With a little bit of code you can change
the location in which the file should be stored. In the code section we
will explore what each and every function does.
Read more