For the past few days, I have been tinkering around with PHP while rebuilding our site at work. I initially did everything in tables and ASP back last year sometime. Just some small stuff, nothing major.
Well, then our Windoze IIS server crashed, and the powers that be decided to move all the web-related stuff over to a Linux/Apache server (a good thing). So there goes my site along with my ability to run ASP, since they aren’t about to try to do any customization for just one loser using ASP. Basically, this was the push I needed to migrate to PHP (another good thing). I’ve been messing around a little bit with PHP, mostly with this site and the WordPress templates. The work site, however, is my first big dive into PHP. I am amazed at the amount (or lack thereof) of PHP code it is taking to redo the site to do basically (or in some cases, more) of the same things it was before. Also, since I’m trying not to use tables (styled ordered lists instead), the size of my templates are just amazing when compared to the tabled ASP templates of the old version. For instance, I have an ASP tabled template that is 46KB in size; the same template done with PHP and CSS-styled order lists: about 4KB (plus about 3KB of included files). Damn! That’s a huge reduction in file size, not to mention the code is gorgeous now without all the tables and that mess in there to clutter it up.
Another thing is adding the last modified date to the pages. In the old version, I used some JavaScript I found somewhere to accomplish this. I looks like so:
<script language="JavaScript"><!–function getLongDateString(){ //method defined on class Date.//Returns a date string of the form: Day DD Month,YYYY//(e.g. Sunday 27 September, 1998)monthNames = new Array("January","February","March","April", "May","June","July","August","September", "October","November","December");dayNames = new Array("Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday");dayOfWeek = this.getDay();day = dayNames[dayOfWeek];dateOfMonth = this.getDate();monthNo = this.getMonth();month = monthNames[monthNo];year = this.getYear();if (year < 2000)year = year + 1900;dateStr = day+", "+month+" "+dateOfMonth+", "+year;return dateStr;}//register the method in the class DateDate.prototype.getLongDateString=getLongDateString;function DocDate(){ //return the document modification date (excl.time)//as a stringDateTimeStr = document.lastModified;secOffset = Date.parse(DateTimeStr);if (secOffset == 0 || secOffset == null) //Opera3.2dateStr = "Unknown";else{aDate = new Date();aDate.setTime(secOffset);//use method defined abovedatestr = aDate.getLongDateString();}return dateStr;}document.write("<center> Last Updated: ");document.writeln(DocDate(),"</center>");//--></script>
Kinda ridiculously long, eh? Then today I ran across this sweet little piece o’ PHP code that I actually inserted into my footer include file that all of my pages will call. This inserts the last modified date of the template neatly onto my pages, and the date format is, of course, customizable:
<?phpputenv("TZ=America/Chicago");echo "Page last modified on " . date( "F d, Y", getlastmod() );?>- Download this code: php-vs-asp-2.txt
So what does all of this mean, and why am I seemingly on a soapbox? Well, I’m very pleased so far with PHP (any surprises there?), what it can do, and the ease of getting it do those tasks. Oh yeah, and what is even better is that I am getting paid to do this. Ain’t life grand?




