Posts Categorized: php

PHP 4 and 5 on IIS

PHP 4 should be long dead, but one of the reasons it isn’t is surely that it can be hard to have 4 and 5 installed on the same server. If you upgrade to 5, you then have to make sure all your PHP sites are still working. And who has time for that? I’ve… Read more »

Posted

Specifying the admin theme for pages in Drupal

Sometimes you want to tell Drupal to use the admin theme on pages other than the ones it decides should be under the admin theme. All you need to do is check the URL in an implementation of hook_init() e.g. function modulename_init(){ if(arg(0) == “whateverpage”){ global $custom_theme; $custom_theme = variable_get(‘admin_theme’, ’0′); } } This is… Read more »

Posted

PHP IDEs

Programming editors are a very personal choice but for serious PHP there are a few must-have features such as autocomplete and code hints (bring up lists of variable and function names, showing parameters) and context-sensitive help (instantly see documentation for a particular function). I’ve used Zend for a while but when Zend for Eclipse was… Read more »

Posted

Installing PHP on Windows

This is for reference – the official docs are a bit messy and there’s been loads of times where it’s taken me hours to track down something silly. Doing it this way allows PHP to be easily upgraded because there’s nothing hanging around in the system directories. Always install it manually – the CGI installer… Read more »

Posted

Generating Word docs from a web app

These are the options I discovered when researching this subject. Number 2 was the best option but it depends on the situation. “Automation” – can use all features of Word (exposed through COM objects) but not recommended for web apps because they interact with the desktop (http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2). Windows only. Need Office installed on the server…. Read more »

Posted

WordPress Email Sending Fix

Sending emails seemed to be broken on this WordPress installation. I’ve seen this before too. The fix is in includes/pluggable-functions.php function wp_mail() Set the from header to from@newmediacollective.com: “From: form@newmediacollective.com\n” WordPress tries to set it to something like wordpress@newmediacollective.com. Our server doesn’t send emails from addresses that don’t exist as a protection against sending spam…. Read more »

Posted

Outputting CSV files in PHP

$output = “col one,col two,col three\r\n”; $output .= “col one,col two,col three\r\n”; header(“Content-type: application/vnd.ms-excel”); header(“Content-disposition: csv; filename=filename.csv; size=”.strlen($output); echo $output;

Posted

PHP UTF-8 tips

It’s not as hard as you might have heard. I’ve finally left my cosy ASCII world and it’s not as bad as I thought. Start with this : http://www.nicknettleton.com/zine/php/php-utf-8-cheatsheet – a checklist of what you need to do. Good reading here : http://www.phpwact.org/php/i18n/charsets. See the links at the bottom of this one. Also added support… Read more »

Posted