June 6th, 2010 by Eric
As PHP applications grow into complex object-oriented systems, developers look to create centralized components to execute repetitive tasks. These include logging, emailing, redirects, and more. The Observer pattern is a commonly used design pattern to hook such components into an application during runtime, thereby making them reusable. Since PHP 5.1, there are two interfaces built into the Standard PHP Library (SPL) that can be implemented to use the Observer pattern in your application. They are SplSubject, and SplObserver.
Continue reading ‘Implementing the Observer Pattern with SplObserver and SplSubject’
May 18th, 2010 by Eric
Today I found a nifty little hack that appears so far to work for IE8 on STSoftware Support Forum. It apparently has to do with the fact that IE8 ignores multiple id selectors.
I decided to test it out on the infamous fieldset – legend IE bug. The display issue came to my attention not by IE, which had been fixed using the usual relative/absolute positioning fix. The “bug” reared its ugly head in Firefox 3.6, which now positions the legend absolutely from the top-right corner within the padding of the fieldset. This being the case, I had to make one of two choices:
- Eliminate the fieldset padding
- Eliminate the absolute/relative positioning built only for IE
I decided to go with option #2. However, to do this we had to preserve positioning one way in IE 6/7, and another way in IE8. This CSS ‘hack’ is actually more of an anti-hack. By that I mean, whatever styles are placed will affect all browsers except IE8. So let’s take a look at how this works.
Continue reading ‘A CSS Hack for Internet Explorer 8′
May 17th, 2010 by Eric
As web developers we are familiar with the DRY (Don’t Repeat Yourself) principle of programming. Cut & paste is the bane of object-oriented programmers, and we will frequently hear the phrase “Don’t reinvent the wheel”. However, I typically find myself and other colleagues in the world of PHP doing just that. The plethora of actively developed PHP Frameworks are a fluid testament to this fact. So are other libraries – sajax/xajax/projax for PHP Ajax work, jQuery/Dojo/Prototype/Mootools for JavaScript, and the list goes on.
Sure, there are unique qualities and features that separate third-party libraries, but the principle overlap is what – 75%? 80%? So why do we do it? The answer may be pride. Or, as someone so excellently put it this past weekend, our answer to “Don’t reinvent the wheel” becomes “Our wheels are rounder”. Continue reading ‘Our Wheels Are Rounder’
May 1st, 2010 by Eric
Yesterday I received a message in my inbox that I had not seen in quite some time:
“New Release of PhpED. 5.9.5 is here”
Over my 2+ years as a PhpED Professional subscriber, I like most became accustomed to regular updates. Be they bugfixes, features, or even just browser and debugger updates – I could be pretty safe in betting on a release every 2-3 weeks. But such has not been the case as of late, and the lack of activity prompted a thread on the NuSphere community forums titled “Future of PHPEd“. Ominous, yes, but a thread that began sour with complaints quickly turned mushy-sweet when NuSphere Customer Support team member gitmans assured everyone that development was very active for PhpED version 6.0! Nice! Continue reading ‘NuSphere Releases PhpEd 5.9.5′
January 9th, 2010 by Eric
I haven’t posted on here in over 2 months, mostly because I have been busy a) fathering 2 girls, and b) working my butt off. Maybe I just haven’t learned many new tricks lately.
However, I found this page yesterday, showing the binary translations of chmod hex commands:
http://catcode.com/teachmod/numeric.html
I can never remember if 5 is “read execute” or “read write”. Well…now, I have a handy reference to remember.
And now, so do you.
October 18th, 2009 by Eric
Have you ever wanted to set up an application that displays tabular data, and wanted to use the same view for each query? While PHP is excellent for writing small-footprint queries, its ability to be embedded in HTML leaves the creativity to the programmer to figure out a consistent display solution for tabular data.
We need two things – first, we need a way to dynamically retrieve table information, query information, and query results. Second, we need a way to dynamically build the display based on the information we have. Using the metadata methods of PDO, along with PEAR::HTML_Table_Matrix, we can do just this. Continue reading ‘Flexible Data Display with PDO and HTML_Table_Matrix’
September 15th, 2009 by Eric
Today I encountered a problem that many developers will likely face while building a web application with Ajax, so I wanted to share my experience with it.
The Problem:
You create a web site with the goal of consuming content from the web. This may be in the form of a geocoding service, or perhaps a lightbox service for browsing images. You need to load an external resource though Ajax. The XMLHttpRequest object cannot make a connection, and you receive a javascript error, or a blank page. Continue reading ‘Writing a Cross-Domain Proxy in PHP’