PHP

Ruby or PHP strftime Without Leading Zeros

The docs for strftime() in both PHP and Ruby seem to assume that you prefer your dates and times to be formatted with leading zeros padding the output to 2 characters. For the minutes, this seems logical enough (4:05 instead of 4:5), but for the hours field it can be a little unattractive (04:05). Here are the format strings you can use for non-zero padded versions of the fields:

%l: The hour in 12-hour format, without a leading zero
%e: The day of the month, without a leading zero

Troubleshooting PHP Include Failures on SUSE10

All PHP includes were failing in my Drupal application on a newly configured SUSE box. After verifying all the permissions, I found that the php.ini file had an extra-secure
include_path variable. Unlike most other distributions it doesn't allow relative path includes. To change that, just modify the
include_path variable like so.

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
include_path = ".:/php/includes"

The change is subtle. Notice the dot before the colon. That

Error 413, Request Entity Too Large

I ran into a problem with a Drupal site today. Any file upload over about 500k was resulting in a "Document Contains No Data" error on Firefox, and an Error 413 "Request Entity Too Large" error on Internet Explorer. Because very small file uploads were working fine, I assumed the problem was file size related.

First I edited /etc/php.ini.


post_max_size = 25M
upload_max_filesize = 20M

Those values showed successfully in phpinfo() calls, but I was still receiving the Request Entity Too Large error. I read somewhere that the apache LimitRequestBody directive may be the culprit. As it turns out, my RedHat Linux distribution sets up a low LimitRequestBody by default. It is increased by editing the /etc/httpd/conf.d/php.conf file.

PHP5 Installation on Windows

There are a few tricks to installing PHP5 and Apache on Windows. This guide will outline the steps I took to get them working together for a development workstation. I have a separate development MySQL server, so I have no need for the full WAMP stack installation. Without that requirement, I've found it's easiest to install PHP5 and Apache separately.
1. Install Apache Binaries

Apache will be installed from the binaries distributed on the Apache mirror network. Grab the newest version MSI file. Install in the default location (c:Program FilesApache GroupApache2).
2. Install PHP Zipped Binaries