A quick reference guide for PHP, with functions references, a regular expression syntax guide and a reference for PHP's date formating functions. As of 28/6/14, the cheat sheet now includes popup links to the appropriate PHP manual pages.
|
^
|
Start of string
|
|
$
|
End of string
|
|
.
|
Any single character
|
|
(a|b)
|
a or b
|
|
(...)
|
Group section
|
|
[abc]
|
In range (a, b or c)
|
|
[^abc]
|
Not in range
|
|
\s
|
White space
|
|
a?
|
Zero or one of a
|
|
a*
|
Zero or more of a
|
|
a*?
|
Zero or more, ungreedy
|
|
a+
|
One or more of a
|
|
a+?
|
One or more, ungreedy
|
|
a{3}
|
Exactly 3 of a
|
|
a{3,}
|
3 or more of a
|
|
a{,6}
|
Up to 6 of a
|
|
a{3,6}
|
3 to 6 of a
|
|
a{3,6}?
|
3 to 6 of a, ungreedy
|
|
\
|
Escape character
|
|
[:punct:]
|
Any punctuation symbol
|
|
[:space:]
|
Any space character
|
|
[:blank:]
|
Space or tab
|
|
g
|
Global match
|
|
i *
|
Case-insensitive
|
|
m *
|
Multiple lines
|
|
s *
|
Treat string as single line
|
|
x *
|
Allow comments and whitespace in pattern
|
|
e *
|
Evaluate replacement
|
|
U *
|
Ungreedy pattern
|
|
r
|
Read
|
|
r+
|
Read and write, prepend
|
|
w
|
Write, truncate
|
|
w+
|
Read and write, truncate
|
|
a
|
Write, append
|
|
a+
|
Read and write, append
|
|
Y
|
4 digit year (2008)
|
|
y
|
2 digit year (08)
|
|
F
|
Long month (January)
|
|
M
|
Short month (Jan)
|
|
m
|
Month ⁴ (01 to 12)
|
|
n
|
Month (1 to 12)
|
|
D
|
Short day name (Mon)
|
|
l
|
Long day name (Monday) (lowercase L)
|
|
d
|
Day ⁴ (01 to 31)
|
|
j
|
Day (1 to 31)
|
|
h
|
12 Hour ⁴ (01 to 12)
|
|
g
|
12 Hour (1 to 12)
|
|
H
|
24 Hour ⁴ (00 to 23)
|
|
G
|
24 Hour (0 to 23)
|
|
i
|
Minutes ⁴ (00 to 59)
|
|
s
|
Seconds ⁴ (00 to 59)
|
|
w
|
Day of week ¹ (0 to 6)
|
|
z
|
Day of year (0 to 365)
|
|
W
|
Week of year ² (1 to 53)
|
|
t
|
Days in month (28 to 31)
|
|
a
|
am or pm
|
|
A
|
AM or PM
|
|
B
|
Swatch Internet Time (000 to 999)
|
|
S
|
Ordinal Suffix (st, nd, rd, th)
|
|
T
|
Timezone of machine (GMT)
|
|
Z
|
Timezone offset (seconds)
|
|
O
|
GMT offset (hours) (+0200)
|
|
I
|
Daylight saving (1 or 0)
|
|
L
|
Leap year (1 or 0)
|
|
U
|
Seconds since Epoch ³
|
|
c
|
ISO 8601 (PHP 5) (2008-07-31T18:30:13+01:00)
|
|
r
|
RFC 2822 (Thu, 31 Jul 2008 18:30:13 +0100)
|
What good is this cheat sheet? It has function names and no descriptions or examples? Is this a wordpress website? WTF!
Nice Thanks :) btw, can you make it a bit more compact? because table break into separated page when download as PDF.
There is a lot missing.
this is better, got some ajax accordion function for clicking
Hi Dave! I recently started learning html,php,mysql and I found your cheatsheets very helpful and also the four security lessons on Php scripting(addedbytes). thanks alot, with bllesings from aboce Anan
Dave, Thanks for adding these. They rock! the mysql and php ones are my faves. Found your site by searching for a SQL Server cheatsheet. all of them are great! Now to dream up one of my own to share. ;0)
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.