Skip Navigation

Find cheat sheets for every topic, or make your own to share with your friends.

All Added Bytes cheat sheets are available free at Cheatography!

Visit Cheatography »

PHP Cheat Sheet (V2)

The second version of the PHP Cheat Sheet, a quick reference guide for PHP, with functions references, a regular expression syntax guide and a reference for PHP's date formating functions.
PHP Cheat Sheet Version 2

Get It Today!

Including:
  - Date format arguments
  - Regular expression syntax
  - Common functions

Buy Now for just $2!

Overview

The PHP cheat sheet is a one-page reference sheet, listing date format arguments, regular expression syntax and common functions.

Updates

July 31st, 2008: Some typos corrected and more examples added to date section. Thanks to Simon Hollingshead for spotting the mistakes and for the suggestions.

What's New?

There are a few small changes from the first version of the PHP Cheat Sheet (which you can still download if you prefer). The most obvious change may be that it now looks different. Hopefully it's now clearer and a little easier to find the information you're looking for.

The content is largely unchanged. The Superglobals list has been removed, and the "function argument orders" section has been changed. Rather than list the orders by themselves, I have expanded the function lists to include function arguments where possible as well.

Function List

Thumbnail highlighting function list. Probably the biggest problem with PHP is its inconsistency. Some function names use underscores, some don't. Some are of the form "verb object" and some are "object verb". Some use "2" instead of "to". These sections of the cheat sheet list many of the most commonly used functions in PHP and are there to provide a quick reference to check function names. These lists include arguments where possible, as PHP's argument ordering is inconsistent between similar functions.

fopen() Modes

Thumbnail highlighting fopen modes. fopen() is a widely used function and has several modes in which it can operate, depending on whether you want to read or write to a file, and what you want to do with data already in that file. This section lists those modes and what each does.

Regular Expression Syntax

Thumbnail highlighting regular expression syntax. Many people have trouble with regular expressions, and the first step to coming to grips with them is to become familiar with the various symbols used in regular expressions and their meaning. This section lists these symbols and describes their meaning.

PCRE Modifiers

Thumbnail highlighting PCRE modifiers. "PCRE" stands for "Perl Compatible Regular Expressions". In PHP, this refers to functions like "preg_replace" and "preg_split". The patterns used in these functions can have modifiers applied to them, and this section list those modifiers and what they do.

Date Formatting

Thumbnail highlighting date formatting. There are, as I'm sure you are aware, a huge number of options when it comes to date formatting, and there are few people who remember all of them. This section of the cheat sheet lists the various options, followed by a description, and an example where appropriate.

Translations

Other Formats

PHP Cheat Sheet Version 2

Get It Today!

Including:
  - Date format arguments
  - Regular expression syntax
  - Common functions

Buy Now for just $2!

The PHP Cheat Sheet is released under a Creative Commons License (Attribution, Non-Commercial, Share Alike).