Archive for the ‘php’ Category

PHP: An Array of Months

Friday, November 16th, 2007

I'll be honest, this isn't very useful. The goal was to have an array of months in the least amount of code. for($i = 1; $i

Reading Raw Post Data in PHP

Wednesday, November 14th, 2007

Perhaps you'd like to just sent XML over post, and not have xml=your_nodes_and_stuff_here. No sweat. $xml = urldecode(file_get_contents('php://input')); Enjoy. This can now be called with: curl -d "some_xml_here" http://yoursite.com/pagename

Motorola RAZR and 406 Not acceptable

Friday, November 9th, 2007

In trying to get a site working on cell phones, I got a "406 Not acceptable" only on the Motorola RAZR. The site loaded fine on my Treo 755 and every Blackberry I've tried. It seems that the RAZR doesn't handle Multiviews very well, or at all for that matter. ...

PHP 4: session_start(): Failed to initialize storage module

Friday, October 12th, 2007

I'm migrating a PHP 4 site right now. It makes me realize how far PHP has come in the last few years. I ran across a weird bug where code was working on our dev server, but not production. I was getting the error: session_start(): Failed to initialize storage ...

PHP: Setting Up XDebug with KCacheGrind

Thursday, July 26th, 2007

KCacheGrind is a very useful tool to identify bottlenecks in your applications. This will explain the steps to using it to find issues with your PHP scripts. For me, the scripts are all web pages. I'm already assuming you're running a current version of PHP. I did this ...

PHP compile error on CentOS Install

Sunday, July 15th, 2007

I installed CentOS 5 on my VMWare a few days ago. I installed gcc via yum, compiled and installed libxml2. I then tried to install PHP 5.2.3 and received this error: configure: error: installation or configuration problem: C++ compiler cannot create executables. It took me forever to figure this out, ...

10 (very) Basic Tips for PHP Web Application Security

Friday, February 23rd, 2007

Barebones list for the things you should be looking for when developing a web app in PHP. Some of it applies to all web apps, not just PHP. Use HTML_Safe (or a similar javascript stripping library) to check for and remove javascript when you're accepting data that will be output ...

What caused that load spike?

Tuesday, February 13th, 2007

Every now and then, we find that we will have a sudden increase in the number of apache processes, load average will spike up, and then go back down to normal. In rare cases, we will see the same thing happen, and the load avg spike WAY up, all ...

Calling a function from within preg_replace

Thursday, October 12th, 2006

Regular expressions are awesome. However, sometimes doing everything in them is extremely difficult, or impossible. Luckily, we can flex the power of preg_replace's 'e' option to execute the replacement string as PHP code. The reason why I found this is was I was looking for a suitable URL auto-linker ...

Pretty URLs using Multiviews

Thursday, October 12th, 2006

I saw a post on digg.com about how it's nice to have "pretty urls" that are easy to tell people. While i'm not sure anyone would remember rustyrazorblade.com slash some ridiculous post name, it's nice to have for search engines. Unfortunately, it didn't really go into detail about ...