code
ref
Cheat Sheets
Quick Reference
JSON Formatter
Learn
Tools
Browser Support
Search…
Ctrl K
Cheat Sheets
/
Languages
/
PHP
PHP
PHP functions for strings, arrays, files, JSON and dates, plus core language features.
Official reference ↗
Strings
Inspect
strlen
str_contains
str_starts_with
str_ends_with
strpos
stripos
strrpos
strcmp
strcasecmp
similar_text
levenshtein
Transform
substr
str_replace
str_ireplace
str_repeat
str_pad
str_split
strtolower
strtoupper
ucfirst
ucwords
lcfirst
trim
ltrim
rtrim
strrev
wordwrap
nl2br
Format & Split
explode
implode
sprintf
printf
number_format
htmlspecialchars
strip_tags
addslashes
md5
sha1
Multibyte
mb_strlen
mb_substr
mb_strtoupper
mb_strtolower
mb_str_split
mb_str_pad
Arrays
Functional
array_map
array_filter
array_reduce
array_walk
array_find
array_any
array_all
Keys & Values
array_keys
array_values
array_key_exists
array_key_first
array_key_last
array_search
in_array
array_flip
array_column
array_combine
array_is_list
Build & Combine
array_merge
array_slice
array_splice
array_chunk
array_fill
array_unique
array_reverse
array_diff
array_intersect
range
compact
extract
Stack & Math
array_push
array_pop
array_shift
array_unshift
array_sum
array_product
count
Sorting
sort
rsort
usort
uasort
uksort
asort
arsort
ksort
krsort
natsort
shuffle
Math
abs
ceil
floor
round
max
min
pow
sqrt
intdiv
fmod
random_int
rand
pi
Variables
isset
empty
unset
is_null
is_array
is_string
is_int
is_numeric
is_bool
is_callable
gettype
get_debug_type
var_dump
print_r
var_export
serialize
unserialize
intval
floatval
boolval
strval
settype
Files
Read & Write
file_get_contents
file_put_contents
file
fopen
fclose
fread
fwrite
fgets
feof
fputcsv
fgetcsv
Filesystem
file_exists
is_file
is_dir
mkdir
rmdir
unlink
rename
copy
scandir
glob
basename
dirname
pathinfo
realpath
filesize
filemtime
tempnam
JSON & Regex
JSON
json_encode
json_decode
json_validate
json_last_error_msg
PCRE
preg_match
preg_match_all
preg_replace
preg_replace_callback
preg_split
preg_quote
Date & Time
Functions
date
time
mktime
strtotime
checkdate
date_default_timezone_set
hrtime
Classes
DateTime
DateTimeImmutable
DateInterval
DateTimeZone
DatePeriod
HTTP & Output
echo
print
header
headers_sent
http_response_code
setcookie
session_start
session_destroy
ob_start
ob_get_clean
filter_var
urlencode
rawurlencode
http_build_query
parse_url
parse_str
base64_encode
base64_decode
password_hash
password_verify
Classes & Functions
Introspection
class_exists
method_exists
property_exists
get_class
get_object_vars
get_parent_class
is_a
is_subclass_of
spl_autoload_register
function_exists
call_user_func
call_user_func_array
func_get_args
Magic Methods
__construct
__destruct
__get
__set
__isset
__unset
__call
__callStatic
__toString
__invoke
__clone
__serialize
__unserialize
Superglobals
$_GET
$_POST
$_SERVER
$_SESSION
$_COOKIE
$_FILES
$_ENV
$_REQUEST
$GLOBALS
Language
Control Structures
if / else
match
switch
foreach
for
while
require_once
include
declare(strict_types=1)
Features
Classes & objects
Interfaces
Traits
Enums
Readonly properties
Property hooks
Attributes
Namespaces
Exceptions
Generators
Closures
Arrow functions
Named arguments
Type declarations
Nullsafe operator ?->
Null coalescing ??