PHP Quick Reference Guide

Under construction.

Language Reference

Basic Syntax

Tags

PHP tag <?php code ?>
Short tag <? code ?>
Short echo tag <?= code ?>
ASP tag <% code %>
ASP echo tag <%= code %>
Script tag <script
language=”php”>
code </script>

Statement Termination

Statements terminated with semicolon

Comments

C++ style // comment to EOL
C style /* comment */
Shell style # comment to EOL

Types

Scalar Types

boolean
integer
float
string

Compound Types

array
object

Special Types

resource
NULL

Pseudo Types

mixed
number
callback
void

Variables

Naming Rules
Scope Rules
Variable Variables
References

Constants

Naming Rules
Scope Rules

Expressions

Type Casts

integer (int), (integer)
Boolean (bool), (boolean)
float (float), (double), (real)
string (string)
array (array)
object (object)
null (unset)

Operators

Arithmetic Operators

Negation -$a
Addition $a + $b
Subtraction $a – $b
Multiplication $a * $b
Division $a / $b
Modulus $a % $b

Assignment Operators

Addition $a += $b
Subtraction $a -= $b
Multiplication $a *= $b
Division $a /= $b
Modulus $a %= $b
Concatenate $a .= $b
Bitwise and $a &= $b
Bitwise or $a |= $b
Bitwise xor $a ^= $b
Bitwise left-shift $a <<= $b
Bitwise right-shift $a >>= $b

Bitwise Operators

not ~$a
and $a & $b
or $a | $b
xor $a ^ $b
left-shift $a << $b
right-shift $a >> $b

Comparison Operators

equal $a == $b
identical $a === $b
not equal $a != $b
not equal $a <> $b
not identical $a !=== $b
less than $a < $b
greater than $a > $b
less or equal $a <= $b
greater or equal $a == $b

Error Control Operators

suppress errors @expr

Execution Operators

execute shell cmd `cmd`

Inc/Dec Operators

pre-increment ++$a
post-increment $a++
pre-decrement –$a
post-decrement $a–

Logical Operators

and $a && $b
and $a and $b
or $a || $b
or $a or $b
xor $a xor $b
not !$a

String Operators

concatenate $a . $b

Array Operators

union $a + $b
equality $a == $b
identity $a === $b
non-identity $a !== $b
inequality $a != $b
inequality $a <> $b

Type Operators

instance of class $a instanceof class

Control Structures

if, else, elseif, else if
switch
while
do while
for
foreach
break
continue
declare
return
require
require_once
include
include_once
goto
Alternative Syntax

Functions

Classes and Objects

Namespaces

Exceptions

Generators

References

Context Options and Parameters

Supported Protocols and Wrappers

Pre-defined Constants

__COMPILER_HALT_OFFSET__
DEFAULT_INCLUDE_PATH
E_ALL
E_COMPILE_ERROR
E_COMPILE_WARNING
E_CORE_ERROR
E_CORE_WARNING
E_DEPRECATED
E_ERROR
E_NOTICE
E_PARSE
E_STRICT
E_USER_DEPRECATED
E_USER_ERROR
E_USER_NOTICE
E_USER_WARNING
E_WARNING
NULL
PEAR_EXTENSION_DIR
PEAR_INSTALL_DIR
PHP_BINARY
PHP_BINDIR
PHP_CONFIG_FILE_PATH
PHP_CONFIG_FILE_SCAN_DIR
PHP_DATADIR
PHP_DEBUG
PHP_EOL
PHP_EXTENSION_DIR
PHP_EXTRA_VERSION
PHP_INT_MAX
PHP_INT_SIZE
PHP_LIBDIR
PHP_LOCALSTATEDIR
PHP_MAJOR_VERSION
PHP_MANDIR
PHP_MAXPATHLEN
PHP_MINOR_VERSION
PHP_OS
PHP_PREFIX
PHP_RELEASE_VERSION
PHP_SAPI
PHP_SHLIB_SUFFIX
PHP_SYSCONFDIR
PHP_VERSION
PHP_VERSION_ID
PHP_ZTS
FALSE
TRUE

Pre-defined Variables

Superglobals
$GLOBALS
$_SERVER
$_GET
$_POST
$_FILES
$_REQUEST
$_ENV
$_COOKIE
$php_errormsg
$HTTP_RAW_POST_DATA
$http_response_header
$argc
$argv

Pre-defined Exceptions

Pre-defined Interfaces and Classes

Function Reference

Arrays

array_change_key_case
array_chunk
array_column
array_combine
array_count_values
array_diff_assoc
array_diff_key
array_diff_uassoc
array_diff_ukey
array_diff
array_fill_keys
array_fill
array_filter
array_flip
array_intersect_assoc
array_intersect_key
array_intersect_uassoc
array_intersect_ukey
array_intersect
array_key_exists
array_keys
array_map
array_merge_recursive
array_merge
array_multisort
array_pad
array_pop
array_product
array_push
array_rand
array_reduce
array_replace_recursive
array_replace
array_reverse
array_search
array_shift
array_slice
array_splice
array_sum
array_udiff_assoc
array_udiff_uassoc
array_udiff
array_uintersect_assoc
array_uintersect_uassoc
array_uintersect
array_unique
array_unshift
array_values
array_walk_recursive
array_walk
array
arsort
asort
compact
count
current
each
end
extract
in_array
key_exists
key
krsort
ksort
list
natcasesort
natsort
next
pos
prev
range
reset
rsort
shuffle
sizeof
sort
uasort
uksort
usort

Calendar

cal_days_in_month
cal_from_jd
cal_info
cal_to_jd
easter_date
easter_days
FrenchToJD
GregorianToJD
JDDayOfWeek
JDMonthName
JDToFrench
JDToGregorian
jdtojewish
JDToJulian
jdtounix
JewishToJD
JulianToJD
unixtojd

Date/Time

checkdate
date_add
date_create_from_format
date_create_immutable_from_format
date_create_immutable
date_create
date_date_set
date_default_timezone_get
date_default_timezone_set
date_diff
date_format
date_get_last_errors
date_interval_create_from_date_string
date_interval_format
date_isodate_set
date_modify
date_offset_get
date_parse_from_format
date_parse
date_sub
date_sun_info
date_sunrise
date_sunset
date_time_set
date_timestamp_get
date_timestamp_set
date_timezone_get
date_timezone_set
date
getdate
gettimeofday
gmdate
gmmktime
gmstrftime
idate
localtime
microtime
mktime
strftime
strptime
strtotime
time
timezone_abbreviations_list
timezone_identifiers_list
timezone_location_get
timezone_name_from_abbr
timezone_name_get
timezone_offset_get
timezone_open
timezone_transitions_get
timezone_version_get

Math

abs
acos
acosh
asin
asinh
atan2
atan
atanh
base_convert
bindec
ceil
cos
cosh
decbin
dechex
decoct
deg2rad
exp
expm1
floor
fmod
getrandmax
hexdec
hypot
is_finite
is_infinite
is_nan
lcg_value
log10
log1p
log
max
min
mt_getrandmax
mt_randlue
mt_srand
octdec
pi
pow
rad2deg
rand
round
sin
sinh
sqrt
srand
tan
tanh

String

addcslashes
addslashes
bin2hex
chop
chr
chunk_split
convert_cyr_string
convert_uudecode
convert_uuencode
count_chars
crc32
crypt
echo
explode
fprintf
get_html_translation_table
hebrev
hebrevc
hex2bin
html_entity_decode
htmlentities
htmlspecialchars_decode
htmlspecialchars
implode
join
lcfirst
levenshtein
localeconv
ltrim
md5_file
md5
metaphone
money_format
nl_langinfo
nl2br
number_format
ord
parse_str
print
printf
quoted_printable_decode
quoted_printable_encode
quotemeta
rtrim
setlocale
sha1_file
sha1
similar_text
soundex
sprintf
sscanf
str_getcsv
str_ireplace
str_pad
str_repeat
str_replace
str_rot13
str_shuffle
str_split
str_word_count
strcasecmp
strchr
strcmp
strcoll
strcspn
strip_tags
stripcslashes
stripos
stripslashes
stristr
strlen
strnatcasecmp
strnatcmp
strncasecmp
strncmp
strpbrk
strpos
strrchr
strrev
strripos
strrpos
strspn
strstr
strtok
strtolower
strtoupper
strtr
substr_compare
substr_count
substr_replace
substr
trim
ucfirst
ucwords
vfprintf
vprintf
vsprintf
wordwrap