Be Wary of User Contributed Notes

This morning, I was reviewing the weekly list of topics with the most comments throughout the PHP manual, and I stumbled upon the following code in the documentation for the date() function. This code is designed to tell you the day of the week for any valid date you give it:


Monday, November 23rd, 2009 @ 1:00 am | Comment (12) | Categories: Technology, General PHP

Why Every Developer Should Write Their Own Framework

Lots of people have the itch to write their own frameworks. They think that they can do better than Zend, Cake, Symfony, or application-level frameworks like Drupal. They’re convinced that those designers and developers made fatal flaws, and they can improve upon them. They’re just itching to give it a shot.

So for those of you wanting to write your own frameworks, feel free. But don’t even think about putting it in production until you’ve read this blog post.

Friday, November 6th, 2009 @ 1:00 am | Comment (38) | Categories: System Architecture, General PHP, Technology

Five Cool PHP Array Functions

Time and time again, I come across code that contains a variety of array-handling functions that too often duplicate the work that the PHP core team has done to develop built-in array functions. Since the built-in functions are inherently faster, trying to reimplement them in PHP will inevitably be a performance problem.

Here are five of my favorite array functions, along with their signatures and what they do.

Wednesday, October 21st, 2009 @ 1:00 am | Comment (22) | Categories: General PHP, Technology, Best Practices
Tags: , ,

How To Write A Function In PHP

PHP allows developers to write a variety of different styles of code: procedural, object-oriented, or simply scripts. This flexibility makes PHP easy to learn, and also means that new developers to PHP may not be programmers in other languages.

Monday, October 12th, 2009 @ 1:00 am | Comment (11) | Categories: General PHP, Technology
Tags: , , ,

Configuring PHP: Essential INI Settings

When setting up a web server with PHP, there are a number of settings that are critical to consider. PHP 5.3 contains both a development INI file and a production INI file; however, users of older PHP releases (or those who don’t have direct control over their INI files) will want to pay attention and make sure that certain settings are configured.

These settings are the settings that I use whenever I configure a PHP server.


Monday, September 28th, 2009 @ 1:00 am | Comment (16) | Categories: General PHP, Best Practices, PHP 5

Avoiding Notices: When to Use isset() and empty()

One of the most confusing things for new programmers (and it even trips me up sometimes) is how to test for boolean conditions in code. As developers, we want to develop code that never emits notices or warnings, and PHP gets a bit antsy when we develop code that utilizes uninitialized variables. Lucky for us, PHP makes it easy to test for these variables without getting these notices.

PHP (like most languages) evaluates a logical argument left to right. For an AND condition, both conditions have to be true; PHP stops evaluating if it finds any condition untrue; that means that we can use isset() or empty() as the first parameter in an if statement, and avoid raising notices.


Wednesday, September 23rd, 2009 @ 1:00 am | Comment (13) | Categories: Best Practices, General PHP
Tags: ,

« Older Entries Newer Entries »

Copyright © 2024 by Brandon Savage. All rights reserved.