PHP

Devolio

Search

PHP Stuff

Monday, August 25. 2008

Data Filtering Using PHP's Filter Functions - Part one

Filtering data. We all have to do it. Most, if not all of us, despise doing it. However, unbeknown to most are PHP's filter_* functions, that allow us to do all sorts of filtering and validation. Using PHP's filter_* functions, we can validate and sanitize data types, URLs, e-mail addresses, IP addresses, strip bad characters, and more, all with relative ease. This is part one of two, covering filter_var() and the different constants and flags that can be set.
Continue reading "Data Filtering Using PHP's Filter Functions - Part one"

Saturday, August 23. 2008

Practical Uses for the PHP Tokenizer

When PHP has to process a request, the engine goes through several passes of parsing until the code is expressed as a set of instructions that the interpreter can execute. The first such step is “lexical scanning”, which splits the code into smaller strings called “tokens”. The token is the smallest meaningful unit of your source code, and it can represent a reserved word (for, while, class, if, etc.), operator (+, -, *, /, && etc.), value literals (integers, floats, strings etc.) and other special symbols.

The same lexical scanner which PHP uses, is also available to userspace PHP developers via the function token_get_all().

Thursday, August 14. 2008

Dynamically Creating Graphs and Charts with PHP and GDChart

If you've been working with PHP for a while, you already know that the language makes dynamic image generation very simple: the GD extension and a few lines of PHP code are all you need to create a JPEG, GIF or PNG image from scratch. However, while this works remarkably well for simple tasks, it can become tedious and complicated if you need to generate more complex images, such as graphs and charts, at run-time.

Thursday, July 10. 2008

Projects abound

I apologize for the lack of updates recently. Between work, meetings, and fun little side projects, I've practically been coding in my sleep. I'll be back to a full time posting schedule soon, I promise. In the mean time, here's a little bit of a description of the projects I've been working on.

Magus - An old school web based RPG / Collectible card game. Collect, buy, sell and trade cards to build powerful decks to duel your opponents. Nearly feature complete, in final testing before our first invite-only release.

Semantic IO - A flexible semantic input/output engine. Enter a file, text, or a URL and pull out an array of useful information. Quickly find phone numbers, addresses, names, or custom searches. Summarize long articles. Find keywords. Automatically tag bodies of text. Full i18n support.

And lastly, I'll be slowly updating and adding (literally) hundreds of research scripts, snippets, and documents to my resources. So - If there's anything specifically that you'd like to improve at or have an idea you want to share or explore - leave a comment. I'd love to hear from some of you lurkers.

Tuesday, May 20. 2008

How to install Apache, MySQL and PHP (LAMP) in Ubuntu 8.04

Just like our Ubuntu 7.10 LAMP how to, this guide will cover the installation of Apache, MySQL and PHP on Ubuntu 8.04. I assume you're already running Ubuntu 8.04 for this guide. If you're still running 7.10, you can use this guide.
Continue reading "How to install Apache, MySQL and PHP (LAMP) in Ubuntu 8.04"

Thursday, February 28. 2008

Practical (and impractical) PHP Optimizations

I've been seeing a lot of articles popping up lately about PHP Optimizations, particularly within the code (rather than the configuration, server, caching, etc) that I have some nitpicks with.

My position remains the same: Unless your code is running incredibly slow, you've found every single bug you can possibly find without having nightmares about unit tests, or an optimization that makes more than a 10% improvement in speed (factoring in your margin of error,) don't bother. That said, let's down to brass tacks.
Continue reading "Practical (and impractical) PHP Optimizations"

Tuesday, February 12. 2008

How to install PHP-GTK in Ubuntu 7.10

Just as described on their site,
"PHP-GTK is an extension for the PHP programming language that implements language bindings for GTK+. It provides an object-oriented interface to GTK+ classes and functions and greatly simplifies writing client-side cross-platform GUI applications."

Basically, it will allow you to use almost everything in the GTK+ API with PHP. If you don't already know what GTK+ is, GTK+ is an API for creating a graphical user interface, which also happens to be cross platform (Linux, Windows, and Mac.) Today we're going to cover installing PHP-GTK in Ubuntu 7.10 (Gutsy).
Continue reading "How to install PHP-GTK in Ubuntu 7.10"

Monday, January 28. 2008

A Simple RSS Reader with SimpleXML

SimpleXML is exactly that: a simple way to handle XML data (including RSS feeds) with PHP5. Today we'll look at using SimpleXML to read and display RSS 1.0 feeds. We'll start by breaking down what information exactly we want to get from our XML file.
Continue reading "A Simple RSS Reader with SimpleXML"

Monday, January 21. 2008

PCRE Tester and Cheat Sheet

Regular Expressions are an extremely powerful tool in any programmers array. Though not always the easiest nuts to crack, so to speak, they are great - when they work correctly. After a rather 'amusing' night of trying to get a complex regular expression to work, I devised a plan.

Why not have both a PCRE Tester and Cheat Sheet on the same page? A tool that allows you to input multiple test strings to make things easier, while being able to look at all of the modifiers and syntax at the same time. The PCRE Tester and Cheat Sheet.

In the near future, I'll also be adding the ability to run preg_replace() instead of preg_match(), and a way to load some of the Regular Expressions from my library, as well as save and add your favorites.

Wednesday, January 9. 2008

How to install APC in Ubuntu 7.10

APC, or Alternative PHP Cache, is a framework for PHP to cache opcodes. Opcodes are the actual instructions that are used when PHP executes scripts. By caching these, you can usually vastly improve performance across the board for PHP based applications. This guide covers installing APC in Ubuntu 7.10 with PHP5 and Apache2.
Continue reading "How to install APC in Ubuntu 7.10"