Zend Framework – Getting Started

Working with a new client project this week that requires the Zend Framework. It’s not my choice of frameworks, but I’m still eager to get going on it. As I’m a bit more familiar with CakePHP, I thought it would be wise to watch a screencast or two about getting started on ZF to see what …

SMARTY: Assigning variables to the header from the body

The problem recently presented itself to me when writing some new functionality for revealCMS: I needed to set some variables to load in the page head, but could only be set after a portion of the body had completed rendering. I wrote a plugin that essentially loads a different stylesheet depending on the input of …

What’s your Fortune?

Here’s a fun little thing you can do for your next site goodie: display your users’ “fortunes” from the command-line interface, CLI, application Fortune. On Fedora, install: % sudo yum install fortune-mod from PHP (fortune.php) <pre> <? passthru(‘fortune’); ?> </pre> I pre-formatted the text because it comes out looking as it does in the CLI. …

Fixing Zen Cart’s Tax Miscalculation When Using a Coupon

I was recently alerted to an error in Zen Cart by a client where the tax was being miscalculated when using a coupon. Here’s the fix. Around line 240 in /store/includes/modules/order_total/ot_coupon.php Remove these lines: //$od_amount[$tax_desc] += (($products[$j][‘final_price’] * $products[$j][‘quantity’]) * $tax_rate)/100 * $ratio; //$od_amount[$tax_desc] += round(((($products[$j][‘final_price’] * $products[$j][‘quantity’]) * $tax_rate) + .5)/100 * $ratio, 2); …

Clean file names using PHP preg_replace

It’s always a good idea to protect yourself from all sorts of possible malicious attempts by users (or even mistakes by misinformed users). Here we look at taking a string of text (a filename) containing characters that are generally speaking unsafe. Here’s a simple way to clean-up filenames (or other text input) using PHP – …

Smart template plugins with Smarty

Smarty is becoming more and more popular in the PHP community lately, especially as developers are moving away from mixing business and display logic in the same scripts and towards a cleaner MVC design pattern implementations. If you’ve followed my blog for any amount of time, you’ll know that I’m currently working on my own …

MySQLi PHP conversion tool

I just got the MySQL AB newsletter in my inbox this evening and there’s an interesting tool they introduce that will convert existing PHP scripts that use the standard (“old”) mysql extension to use the new mysqli. “i” stands for “improved” – the new extension is faster and can take advantage of the new MySQL …

Interview questions… for a PHP job

Last week I went through one and a half hellish days of interviewing candidates for my replacement – one position for PHP and another for the research coordinating. Larry and I talked to over a dozen people. It wasn’t bad, per-se, but I wouldn’t do so many all at once again. It really made me …

Hey there! Come check out all-new content at my new mistercameron.com!