Week 5: php scripts
[ objectives
| links | activity ]
Objectives
[ top
]
By the end of this online
week, you will
-
be able to explain what php
scripts are and how they differ from CGI scripts written (typically)
in PERL
-
be able to state why php tends
to be used as a 'glue script' for database powered applications
-
have downloaded, configured,
uploaded and tested a simple php Web Server application that does
not use a database
Differences: php code
is mixed with html codes in pages. These pages are then given the file
extension .php or .phtml. When a given page is requested by the user's
Web browser, the php script interpreter loads the code in the page
and runs the code. The output from the script is delivered to the Web browser
as a Web page. The user never sees the original code. In CGI PERL scripts,
the code is held in a separate file from the HTML pages. PERL scripts generate
HTML pages by either saving output as HTML pages on the server or by 'including'
output on HTML pages with templates embedded in them. The php script engine
has built in support for most commonly found relational databases: MySQL
being very popular on UNIX based Web servers.
Database backends:
Setting up a MySQL database account on most UNIX web server accounts is
simply a matter of e-mailing the support people. They will send the address
of the MySQL server (usually 'http://localhost' as it is on the same server
as your Web space), the name of the database, and a user id/password for
connecting to the database. Most MySQL based backends have a configuration
file where you provide these details. The tricky bit is sometimes setting
up the database tables, but, increasingly that process is being automated
with setup scripts. If you do have to set up database tables manually,
most Web server hosting packages now have a Web page based admin system
for databases.
Web
Links
[ top
]
Activity
[ top
]
Keith
Burnett
Last modified: 2nd Feb 03