Web Analytics

PHP Functions Reference

Interactive reference for PHP's most useful built-in functions. Browse by category, search, and run live examples.

+-
Math Functions
7 functions
{}
JSON Functions
2 functions
$
Variable Functions
5 functions

All Functions

Function Description Category
strlen() Returns the length of a string String
str_replace() Replace all occurrences of search string with replacement String
substr() Return part of a string String
strpos() Find the position of the first occurrence of a substring String
explode() Split a string by a delimiter into an array String
implode() Join array elements into a string String
trim() Strip whitespace from beginning and end of a string String
strtolower() Convert a string to lowercase String
strtoupper() Convert a string to uppercase String
sprintf() Return a formatted string String
array_map() Apply a callback function to each element of an array Array
array_filter() Filter elements of an array using a callback function Array
array_merge() Merge one or more arrays Array
array_push() Push one or more elements onto the end of array Array
array_pop() Pop the element off the end of array Array
array_search() Search array for a value and return its key Array
in_array() Check if a value exists in an array Array
array_keys() Return all keys of an array Array
array_values() Return all values of an array Array
sort(), array_splice(), count(), krsort(), ksort(), natcasesort(), natsort(), range(), rsort(), shuffle() Sort an array in ascending order Array
round() Round a float to the nearest integer Math
floor() Round a number down to the nearest integer Math
ceil() Round a number up to the nearest integer Math
abs() Return the absolute value of a number Math
rand() Generate a random integer Math
max() Find the highest value Math
min() Find the lowest value Math
date() Format a local date/time Date
time() Return current Unix timestamp Date
strtotime() Parse English textual datetime to Unix timestamp Date
mktime() Get Unix timestamp for a date Date
checkdate() Validate a Gregorian date Date
getdate() Get date/time information Date
gettimeofday() Get current time Date
gmdate() Format a GMT/UTC date/time Date
gmmktime() Get Unix timestamp for a GMT date Date
gmstrftime() Format a GMT/UTC time/date according to locale settings Date
hrtime() Get high resolution time Date
idate() Format a local time/date as integer Date
localtime() Get the local time Date
microtime() Return current Unix timestamp with microseconds Date
strftime() Format a local time/date according to locale settings Date
strptime() Parse a time/date generated with strftime() Date
cal_days_in_month() Return number of days in a month for a given year and calendar Calendar
cal_from_jd() Converts from Julian Day Count to a supported calendar Calendar
cal_info() Returns information about a particular calendar Calendar
cal_to_jd() Converts from a supported calendar to Julian Day Count Calendar
easter_date() Get Unix timestamp for midnight on Easter of a given year Calendar
easter_days() Get number of days after March 21 on which Easter falls for a given year Calendar
frenchtojd() Converts a date from the French Republican Calendar to a Julian Day Count Calendar
gregoriantojd() Converts a Gregorian date to Julian Day Count Calendar
jddayofweek() Returns the day of the week Calendar
jdmonthname() Returns a month name Calendar
jdtofrench() Converts a Julian Day Count to the French Republican Calendar Calendar
jdtogregorian() Converts Julian Day Count to Gregorian date Calendar
jdtojewish() Converts a Julian day count to a Jewish calendar date Calendar
jdtojulian() Converts a Julian Day Count to a Julian Calendar Date Calendar
jdtounix() Convert Julian Day to Unix timestamp Calendar
jewishtojd() Converts a date in the Jewish Calendar to Julian Day Count Calendar
juliantojd() Converts a Julian Calendar date to Julian Day Count Calendar
unixtojd() Convert Unix timestamp to Julian Day Calendar
json_encode() Convert a value to JSON JSON
json_decode() Decode a JSON string JSON
file_get_contents() Read entire file into a string File
file_put_contents() Write data to a file File
file_exists() Check whether a file or directory exists File
isset() Determine if a variable is set and is not null Variable
empty() Determine whether a variable is empty Variable
var_dump() Dump information about a variable Variable
print_r() Print human-readable info about a variable Variable
gettype() Get the type of a variable Variable
hash() Generate a hash value (message digest) Hash
hash_algos() Return a list of registered hashing algorithms Hash
hash_equals() Timing attack safe string comparison Hash
hash_hkdf() Generate a HKDF key derivation Hash
hash_hmac() Generate a keyed hash value using HMAC Hash
hash_hmac_algos() Return algorithms suitable for hash_hmac Hash
hash_pbkdf2() Generate a PBKDF2 key derivation Hash
random_bytes() Generate cryptographically secure random bytes Hash
random_int() Generate cryptographically secure random integers Hash
password_hash() Creates a password hash Password
password_verify() Verifies that a password matches a hash Password
password_algos() Get available password hashing algorithm IDs Password
password_get_info() Returns information about the given hash Password
password_needs_rehash() Checks if the hash matches the given options Password
preg_match() Perform a regular expression match Regex
preg_match_all() Perform a global regular expression match Regex
preg_replace() Perform a regex search and replace Regex
preg_replace_callback() Regex search and replace using a callback Regex
preg_split() Split string by a regular expression Regex
preg_grep() Return array entries that match the pattern Regex
preg_filter() Perform regex search and replace, return matches Regex
preg_quote() Quote regular expression characters Regex
urlencode() URL-encodes string URL
urldecode() Decodes URL-encoded string URL
rawurlencode() URL-encode according to RFC 3986 URL
rawurldecode() Decode URL-encoded strings URL
base64_encode() Encodes data with MIME base64 URL
base64_decode() Decodes data encoded with MIME base64 URL
parse_url() Parse a URL and return its components URL
http_build_query() Generate URL-encoded query string URL
get_meta_tags() Extracts all meta tag content attributes URL
gethostbyaddr() Get hostname from IP address (reverse DNS) Network
gethostbyname() Get IPv4 address from hostname (DNS lookup) Network
gethostbynamel() Get list of IPv4 addresses for a hostname Network
getmxrr() Get MX records for a domain Network
getservbyname() Get port number for a service name Network
getservbyport() Get service name for a port number Network
ip2long() Convert IPv4 address to integer Network
long2ip() Convert integer to IPv4 address Network
hex2bin() Decodes a hexadecimally encoded binary string General
pack() Pack data into binary string General
serialize() Generates a storable representation of a value General
token_name() Get the symbolic name of a given PHP token General
uniqid() Generate a unique ID General
unpack() Unpack data from binary string General
unserialize() Creates a PHP value from a stored representation General
zlib_decode() Uncompress any raw/gzip/zlib encoded data General
zlib_encode() Compress data with the specified encoding General