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 →
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 →
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.
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 →
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 →
I have created a new page for featuring little snippets of code that I think others may find useful. Its name, quite uncreative, is “Useful Scripts”.
http://codemill.studio-connect.com/useful-scripts/
The first function posted is for getting the difference between two dates. This function takes two dates that are convertible to Unix timestamps using strtotime(), and will return an array of the number of years/months/days between the two dates. The number of days between a leap and non-leap year is not correct yet, that is on my to-do list.
PHP 5.3 introduces the new DateInterval class which will help parse dates and provide native dateDiff functionality to PHP. Until we are all on 5.3, hopefully this will help someone else.
Until next time.
I wanted to write a quick post about a library one of my co-workers stumbled upon this week. It is called php.js and is a compilation of php functions ported to javascript. That sounds pretty convenient!
Continue reading →