Why this site is in PHP?
If you've taken a look at the page names you may be wondering why this page is in PHP. After all, we do Java here, so why isn't the web site implemented in Java?
The first reason is cost. PHP is the cheapest way to get your site up if all you want is basic HTML flavoured with the odd dynamic script. That's all I wanted. I'm not using a database. Web hosting outfits that offer a cheap shared server Java-based solution are like hens teeth. www.webconexion.net looks like a good bet, but it one of very few.
One of the great promises of Content Management Systems (CMS) is that you don't need to be technical at all to edit your site. All you need to do is type your content into your administration interface and it appears on your site. I spent quite a few days ferreting around the web looking for a really good open source CMS. I was quite impressed by a couple (Magnolia for example), but they all looked a little heavyweight for my needs. A real sledgehammer and nut scenario for my simple requirements. During this search I came across the perfect tool for my needs, which I am using at this moment. It's called HTML Area, and it lets you edit your HTML content in WYSIWYG fashion while generating clean code underneath. Here's the link - it's great stuff: HTMLArea
Otherwise, I've found PHP a really neat environment, perfect for a simple web site job. I wouldn't want to use PHP for a larger project, though. This is because you don't get good encapsulation of functionality the way you'd get with an object-oriented language like Java. You also don't get any application layering. If the application ever became complex, it would quickly turn into a complete mish-mash of HTML and dynamic code.
I think if the site ever gets complex enough to need a database, then I might need to rethink my implementation choice. With so many other things to do, I don't see this happening for quite a while yet, especially while I'm the only person adding content to the site.
Anyway, its been quite fun using PHP. I found the PHP Manual on www.php.net very useful. The main techniques I use are:
require()
function as an include mechanism:
<?php require("header.php"); ?>
So that the body pages can be minimal in complexity
<?php require("header.php"); ?>
<P><H2>Welcome</H2></P>
<P>Welcome to <STRONG>Realsolve</STRONG>, a software development and training
consultancy. Our mission is to deliver the highest level of customer
satisfaction at a reasonable cost.</P>
<P>We deliver robust, maintainable and highly performant applications built
using software development best practices. Our areas of specialism are:</P>
<UL>
<LI><A href="business_dev_integration.php">business application development and
integration</A>
<LI><A href="web_development.php">web application development</A>
<LI><A href="database_development.php">database development</A></LI></UL>
<P>We are specialists in the development of applications using <STRONG>Java</STRONG> and related technologies.</P>
<?php require("footer.html"); ?>
htmlspecialchars() function to turn a piece of
raw code text into an HTML format
<PRE>
<?php
$file = 'codesnippet.htm';
$fullfile = $file;
$mainbody = implode ('', file($fullfile));
print htmlspecialchars($mainbody, ENT_QUOTES);
?>
</PRE>
The HTML for this looks like this:
<PRE> <?php $file = 'codesnippet.htm'; $fullfile = $file; $mainbody = implode ('', file($fullfile)); print htmlspecialchars($mainbody, ENT_QUOTES); ?> </PRE>
The other main requirement is that the pages should be very simple, easy to update and printable. Web pages print much better when they are allowed to scale with the browser rather than be confined to fixed widths, so I'm using a rather dull but very functional layout to allow for easy printing without having to generate separate printable pages.
Finally, layout data such as fonts, colours and styles are kept in two stylesheets: realsolve.css (for the main site section) and tech.css (for the technical stuff), making updating the look and feel quite easy (something I'm doing quite often at the moment).