Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

PHP All-In-One Cheat Sheet, Cheat Sheet of Programming Languages

All-In-One Cheat Sheet on PhP, open source scripting language: main fonctions

Typology: Cheat Sheet

2019/2020

Uploaded on 10/09/2020

ahalya
ahalya 🇺🇸

4.9

(16)

257 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Array Functions
array_diff (arr1, arr2 ...)
array_filter (arr, function)
array_flip (arr)
array_intersect (arr1, arr2 ...)
array_merge (arr1, arr2 ...)
array_pop (arr)
array_push (arr, var1, var2 ...)
array_reverse (arr)
array_search (needle, arr)
array_walk (arr, function)
count (count)
in_array (needle, haystack)
Date and Time Functions
date (format, timestamp)
mktime (hr, min, sec, month, day, yr)
strtotime (str)
time ()
Filesystem Functions
clearstatcache ()
copy (source, dest)
fclose (handle)
fgets (handle, len)
file (file)
filemtime (file)
filesize (file)
file_exists (file)
fopen (file, mode)
fread (handle, len)
fwrite (handle, str)
readfile (file)
Regular Expression Functions
ereg (pattern, str)
split (pattern, str)
ereg_replace (pattern, replace, str)
preg_grep (pattern, arr)
preg_match (patten, str)
preg_match_all (pattern, str, arr)
preg_replace (pattern, replace, str)
preg_split (pattern, str)
String Functions
crypt (str, salt)
explode (sep, str)
implode (glue, arr)
nl2br (str)
sprintf (frmt, args)
strip_tags (str, allowed_tags)
str_replace (search, replace, str)
strpos (str, needle)
strrev (str)
strstr (str, needle)
strtolower (str)
strtoupper (str)
substr (string, start, len)
fopen() Modes
r
r+
w
w+
a
a+
Read
Read and write, prepend
Write, truncate
Read and write, truncate
Write, append
Read and write, append
Available free from
AddedBytes.com
PCRE Modifiers
i
s
m
U
e
x
Case-insensitive
Period matches newline
^ and $ match lines
Ungreedy matching
Evaluate replacement
Pattern over several lines
Date Formatting
Regular Expressions Syntax
^
$
.
(a|b)
(...)
[abc]
[^abc]
\s
a?
a*
a*?
a+
a+?
a{3}
a{3,}
a{3,6}
a{3,6}?
\
[:punct:]
[:space:]
[:blank:]
Start of string
End of string
Any single character
a or b
Group section
Item in range (a, b or c)
Not in range (not a, b or c)
White space
Zero or one of a
Zero or more of a
Zero or more of a, ungreedy
One or more of a
One or more of a, ungreedy
Exactly 3 of a
3 or more of a
3 to 6 of a
3 to 6 of a, ungreedy
Escape character
Any punctuation symbol
Any space character
Space or tab
Y
y
F
M
m
n
D
l
d
j
h
g
H
G
i
s
w
z
W
t
a
A
B
S
T
Z
O
I
L
U
c
r
1.
2.
3.
4.
4 digit year (2008)
2 digit year (08)
Long month (January)
Short month (Jan)
Month 4 (01 to 12)
Month (1 to 12)
Short day name (Mon)
Long day name (Monday)
Day 4 (01 to 31)
Day (1 to 31)
12 Hour 4 (01 to 12)
12 Hour (1 ro 12)
24 Hour 4 (00 to 23)
24 Hour (0 to 23)
Minutes 4 (00 to 59)
Seconds 4 (00 to 59)
Day of week 1 (0 to 6)
Day of year (0 to 365)
Week of year 2 (1 to 53)
Days in month (28 to 31)
am or pm
AM or PM
Swatch Internet Time (000 to 999)
Ordinal Suffix (st, nd, rd, th)
Timezone of machine (GMT)
Timezone offset (seconds)
Difference to GMT (hours) (+0200)
Daylight saving (1 or 0)
Leap year (1 or 0)
Seconds since Epoch 3
ISO 8601 (PHP 5)
RFC 2822
0 is Sunday, 6 is Saturday.
Week that overlaps two years belongs
to year that contains most days of that
week. Hence week number for 1st
January of a given year can be 53 if
week belongs to previous year.
date("W", mktime(0, 0, 0, 12, 8,
$year)) always gives correct number
of weeks in $year.
The Epoch is the 1st January 1970.
With leading zeroes

Partial preview of the text

Download PHP All-In-One Cheat Sheet and more Cheat Sheet Programming Languages in PDF only on Docsity!

Array Functions

array_diff (arr1, arr2 ...) array_filter (arr, function) array_flip (arr) array_intersect (arr1, arr2 ...) array_merge (arr1, arr2 ...) array_pop (arr) array_push (arr, var1, var2 ...) array_reverse (arr) array_search (needle, arr) array_walk (arr, function) count (count) in_array (needle, haystack)

Date and Time Functions

date (format, timestamp) mktime (hr, min, sec, month, day, yr) strtotime (str) time ()

Filesystem Functions

clearstatcache () copy (source, dest) fclose (handle) fgets (handle, len) file (file) filemtime (file) filesize (file) file_exists (file) fopen (file, mode) fread (handle, len) fwrite (handle, str) readfile (file)

Regular Expression Functions

ereg (pattern, str) split (pattern, str) ereg_replace (pattern, replace, str) preg_grep (pattern, arr) preg_match (patten, str) preg_match_all (pattern, str, arr) preg_replace (pattern, replace, str) preg_split (pattern, str)

String Functions

crypt (str, salt) explode (sep, str) implode (glue, arr) nl2br (str) sprintf (frmt, args) strip_tags (str, allowed_tags) str_replace (search, replace, str) strpos (str, needle) strrev (str) strstr (str, needle) strtolower (str) strtoupper (str) substr (string, start, len)

fopen() Modes

r r+ w w+ a a+

Read Read and write, prepend Write, truncate Read and write, truncate Write, append Read and write, append

Available free from AddedBytes.com

PCRE Modifiers

i s m U e x Case-insensitive Period matches newline ^ and $ match lines Ungreedy matching Evaluate replacement Pattern over several lines

Date Formatting

Regular Expressions Syntax

^ $ . (a|b) (...) [abc] [^abc] \s a? a* a*? a+ a+? a{3} a{3,} a{3,6} a{3,6}? \

[:punct:] [:space:] [:blank:]

Start of string End of string Any single character a or b Group section Item in range (a, b or c) Not in range (not a, b or c) White space Zero or one of a Zero or more of a Zero or more of a, ungreedy One or more of a One or more of a, ungreedy Exactly 3 of a 3 or more of a 3 to 6 of a 3 to 6 of a, ungreedy Escape character

Any punctuation symbol Any space character Space or tab

Y y F M m n D l d j h g H G i s w z W t a A B S T Z O I L U c r

4 digit year (2008) 2 digit year (08) Long month (January) Short month (Jan) Month 4 (01 to 12) Month (1 to 12) Short day name (Mon) Long day name (Monday) Day 4 (01 to 31) Day (1 to 31)

12 Hour 4 (01 to 12) 12 Hour (1 ro 12) 24 Hour 4 (00 to 23) 24 Hour (0 to 23) Minutes 4 (00 to 59) Seconds 4 (00 to 59)

Day of week 1 (0 to 6) Day of year (0 to 365) Week of year 2 (1 to 53) Days in month (28 to 31)

am or pm AM or PM Swatch Internet Time (000 to 999) Ordinal Suffix (st, nd, rd, th)

Timezone of machine (GMT) Timezone offset (seconds) Difference to GMT (hours) (+0200) Daylight saving (1 or 0) Leap year (1 or 0)

Seconds since Epoch 3 ISO 8601 (PHP 5) RFC 2822

0 is Sunday, 6 is Saturday.

Week that overlaps two years belongs to year that contains most days of that week. Hence week number for 1st January of a given year can be 53 if week belongs to previous year. date("W", mktime(0, 0, 0, 12, 8, $year)) always gives correct number of weeks in $year.

The Epoch is the 1st January 1970.

With leading zeroes