recent posts related to the php programming language

How to display the APC Opcode Cache information page

I just finished moving the website to a newer, faster web server, and in the process I had to install the APC Opcode Cache on the new server. After installing APC, I like to be able to test that it's working, so I wanted to be able to display the APC information web page (APC test page).

To display the APC test/information page, just:

Free PHP charts and graphs

As I embark on two new PHP web applications that have a lot of charting and graphing needs, I've started to dig into the PHP charts and graphs world. I'm pleased to say there are several nice, free PHP charts and graphs tools available, and several commercial PHP charting/graphing tools as well. Here's my quick review of the current PHP charts and graphs tools.

Creating a PHP date in the format for a SQL Timestamp insert

PHP date/time FAQ: How do I create a date in the proper format to insert a SQL Timestamp field into a SQL database?

First off, you may not need to create a date in PHP like this. If you're using plain old PHP and a database like MySQL, you can use the SQL 'now()' function to insert data into a SQL timestamp field, like this:

PHP ping script examples

While working on a shared hosting server, I found that the company I'm working with has disabled my access to the Unix/Linux ping command. Not to be deterred, I found several different ways to run a ping command with a PHP script.

Use the Net_Ping module

The first thing you can try to do is use the PHP PEAR Net_Ping module to get around this problem. In short, you install it like this:

pear install Net_Ping

Then use it like this:

Solution for PEAR or PECL "is using a unsupported protocal (sic)"

Summary: A solution for "pear/pecl is using a unsupported protocal (protocol)".

While trying to install the APC Opcode Cache on a server yesterday, when I tried to run this command:

pecl install apc

I kept getting this error message: is using a unsupported protocal - 
This should never happen.
install failed

After doing some research, it looks like you can also get a similar error message with PEAR:

PHP warning - Unable to load dynamic library ./ (Solution)

While installing the PHP APC opcode cache, I just ran into the following error:

PHP Warning:  PHP Startup: Unable to load dynamic library './' - ./ 
cannot open shared object file: No such file or directory in Unknown on line 0

I found this error message in my PHP error log, but depending on your configuration I think it may also be in your Apache error log file.

An Apache 301 redirect for a deleted directory

I recently reorganized the website, and as part of that, I deleted an entire directory at the root level that was named "/Dir". This was the "directory", where I had a Yahoo-like directory of links to applets, tutorials, CGI scripts, and so on, so I had thousands of web pages with URLs like these:

A simple, printable calendar

If you've ever wanted a simple, printable calendar you can print and then put up on your refrigerator, I just created one over on the Valley Programming website. Here's a link to my simple printable calendar blog post over there. And fwiw, here's an image to give you a little idea of what the calendar looks like:

A PHP “string to date” example

Summary: A PHP “string to date” conversion example.

For a recent PHP calendar project I needed to convert a given string into a 'date' I could work with more easily. In short, given a string date like this:


I wanted to convert that to some type of PHP date data structure I could use to render a calendar.

PHP string to date source code

The following PHP code shows the two steps I used to convert a date string into a PHP date structure I could work with:

PHP job interview questions

Summary: A collection of PHP job interview questions (and other standard computer programming interview questions).

Over the years, I've found the best way to find out how a potential programmer works is to sit with him at a computer keyboard and write some code, typically something requiring some database interaction, and potentially interaction with another developer.