|
PHP is a server-side processing language which integrates with
HTML to produce HTML code which is browser independent. Its advantages
include:
Object-oriented |
PHP is not fully object-oriented but supports
object-oriented concepts. An object-oriented approach allows
for objects to be more easily managed, and controlled. |
Cross-platform |
The other major server-side include languages, such as
ASP and JSP, are focused as a certain WWW platform. ASP is
focused on the Windows-based IIS. PHP has been designed to
work on many different types of WWW server platforms, and
hardware. It can be easily integrated in most types of WWW
server. |
Database integration |
PHP can be integrated with most of the popular database
systems, including MySQL, Oracle and Sybase. |
Version updates |
PHP is continually updated, with new version. It is this
a dynamic language which can be quickly changed by upgrading
its component parts. The upgrad-ing of server side components
are simpler, than upgrading WWW browsers, as the update of
the server only requires a single operation, while the upgrade
of WWW browsers requires that every user upgrades their browser. |
Enhanced security |
PHP hides the original code from the user, as they will
only see the processed code, thus more security can be built
into the code, such as determining the location of the WWW
browser, and determining the rights that the user has in viewing
information. |
Enhanced development
tools |
PHP has a whole host of development tools so the creating
and testing of PHP code. |
The main WWW server platforms include:
IIS
(Internet Information Server) |
This server will run on a Windows NT/2000/XP-server type
platform, and directly supports ASP as the server-side include
language. By default the Inetpub directory is the home directory
for the WWW server. Users accessing the WWW server will not
be able to get access to any directories above this. The security
of the system is important, thus the Inetpub directory must
be created on an NTFS partition. |
Apache |
This server was originally developed by the Apache Group,
and used the UNIX operating system. It has now been converted
to support most types of operating systems, and computer types.
The full code of the Apache program is available to that it
can be modified for certain uses. PHP is the natural server-side
language for Apache. The Apache server program reads the httpd.conf
file for most of its operating parameters.
|
PWS
(Personal Web Server) |
This can be used with Workstation-type Windows-based systems,
and allows users to setup their own WWW server on their own
computer. It supports ASP directly, and can be made to support
PHP, with the addition of additional components. As with IIS,
the Inetpub directory should be mounted onto an NTFS partition.
|
PHP is installed onto a Windows-based Apache server by downloading
the PHP program from www.php.net
(or from the supplied CD), and installing it into a directory such
as C:\PHP. It is then added into the server by adding the following
lines in the httpd.conf file:
Inserted code
into httpd.conf file |
| LoadModule
php4_module c:/php/sapi/php4apache.dll
AddModule mod_php4.c
AddType application/x-httpd-php .php |
and php4ts.dll file is put into the %WINDOWSROOR%\SYSTEM32 directory.
The httpd.conf file can then be modified for the required operating
parameters, such as the home directory for the configuration, error
and log files with:
Modifying the
home directory in the httpd.conf file |
| ServerRoot
"C:/Program files/Apache group\Apache" |
or for the root directory of the WWW site with:
Modifying the
home directory in the httpd.conf file |
| DocumentRoot
"C:/www" |
In PHP the additional code is added between the <? and ?>
tags. For example the following prints a "Hello World"
message to the browser:
PHP code |
| <?php
print("Hello World");
?> |
The development system already comes with a PHP.EXE program
which can be used as a standalone package to convert from PHP to
HTML. For example, a simple PHP file is:
Orginal file
(simple.php) |
| <html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF"
text="#000000">
<?php
print("Hello World");
?>
</body>
</html> |
when this is processed by PHP.EXE (php
simple.php > simple.html) it gives the following PHP file:
Processed file
(simple.php) |
| X-Powered-By:
PHP/4.1.2
Content-type: text/html
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF"
text="#000000">
Hello World
</body>
</html> |
This is the form that the WWW browser would expect to see, as it
contains the HTTP header information, along with the HTML code.
The output is:
|