PHP 5.1 JSON

If you need the JSON support functions json_encode and json_decode, but your server is not running PHP 5.2+, consider using the Zend framework.

One of the nicest things about the JSON support is that it will use json_encode and json_decode if they are available, if not, it will handle it.

Zend framework can be used as a library, so if all you need is the JSON support, you won’t incur alot of overhead.

The new version of Zend Framework includes dojo!

Change image colors with Jasc Paint Shop Pro

To take the colors from one image and apply them to another, the following approach yields the best results:

  1. Open the two images
  2. Set the focus to the target color set and save the palette. Colors > Save Palette. You may have to convert the source image to a .gif for this to work.
  3. Set the focus on the image to be recolored and load the saved palette. Colors > Load Palette

Bear in mind that if you have alot of images, you may want to pursue batch processing, either through the GUI, macros, workspace, or command line options.

This approach will probably work for any powerful image editing software, however, its success is dependent on the images and colors involved. Not all images can easily be recolored.

Comments - Etiquette

Comments are added to code to assist the reader in understanding the code. The following guidelines should be observed:

  • Comments should not be written to editorialize or entertain. Sarcasm should not be in comments. Questions can be placed in comments, where necessary, to ensure issues are identified and resolved.
  • Proper grammar and spelling are required. It reduces the opportunties for misunderstanding.
  • Comments, especially in an interpretive environment such as PHP, should be brief. Utilities that strip comments for distribution can eliminate this requirement.
  • Careful coding, with meaningful function and variable names may reduce the need for comments. Overly complex statements should be avoided.
  • Comments should be considered a visible part of the deliverable product and should be of appropriate quality. If it is a professional product, comments should be professional.
  • Comments must be updated to remain current as the code changes.

RIA server filesystem architecture

The /opt directory can be used to store shared components, as follows:

  • /opt/os - All open source components

  • /opt/common - All common scripts, such as form validation for contact us forms, anti-spam code.

    • /antispam

      • /html - (html and javascript) - to assist the user
      • /php - to protect the server
    • /footer - Footer text, specifically the company name and copyright indicator. This ensures it can be changed in one place to update every page on the server.

New accounts could access these components like so:


ln -s /opt/os/dojo 
ln -s /opt/os/Smarty 
ln -s /opt/os/Zend
ln -s /opt/common/html 
ln -s /opt/common/php
ln -s /opt/common/footer

These links allow relative references to the common resources, while providing central sourcing.

GUI vs. Command Line

There are many powerful GUIs to assist web professionals, and, they are excellent. They often allow people to perform tasks that they would not otherwise be able to. This is valuable for inexperienced users, however, it is not an excuse to be casual with skills.

When you must get something done, and the GUI is the fastest way to achieve the goal, the GUI is vital. However, when you have a little bit of time, it is definitely worth understanding what the GUI is doing, and learning how to do it on the command line.

Most GUIs provide displays to show the underlying actions. phpMyAdmin provides a GUI to create the queries, but also displays the MySQL. It can be a great learning tool.

Command line control is usually faster than a GUI. The GUI protects you from errors, by guiding you through the operations step by step. On the command line, you can enter exactly what you want. If there is an error, you’ll usually get a message. Potential catastrophic operations are usually preceded with some sort of warning or confirmation.

Finally, there are times when the GUI won’t work, or you won’t have one. If you can use the command line, you will still be able to do all the work.