Home >PHP >PHP reference – functions

PHP reference – functions

An overview of PHP functions with examples, grouped by topic: strings and multibyte strings, arrays, math, variables and types, date and time, files, HTTP and sessions, hashing and encryption, regular expressions and JSON, output and errors, cURL, images (GD and EXIF), mysqli and XML. The outputs of the examples are real – the code was run in PHP 7.4 and PHP 8.5 (the sodium functions in PHP 8.5 only).

Strings 81 entries

  • addslashes Returns a string with a backslash added before every apostrophe, double quote, backslash and null byte.
  • base64_decode Converts Base64 text back to the original data.
  • base64_encode Encodes any data (text or binary content) as text made only of letters, digits and the characters + / =.
  • bin2hex Converts a string to hexadecimal notation: every byte is replaced with two characters 0–9 and a–f.
  • chr Returns a one-character string containing the character specified by the parameter $ascii_code.
  • chunk_split Splits a string into parts of the given length and inserts a separator after each one.
  • count_chars Counts the occurrences of individual bytes in a text.
  • explode Splits the string $string by the separator $separator and returns an array of the parts.
  • fprintf Writes text built from a format (just like sprintf()) to an open file or stream.
  • get_html_translation_table Returns an array whose keys are characters and whose values are their HTML entities.
  • hex2bin Converts hexadecimal notation back to data: every two characters 0–9 and a–f become one byte.
  • html_entity_decode Converts HTML entities in a text back to characters.
  • htmlentities Converts every character for which an entity exists into an HTML entity.
  • htmlspecialchars Converts the characters that have a special meaning in HTML (& < > " ') to HTML entities.
  • htmlspecialchars_decode Converts back to characters only the entities that htmlspecialchars() creates: &amp;, &lt;, &gt;, &quot; and the apostrophe entity.
  • implode Joins the values of the array $array into one string and puts $separator between the individual values.
  • lcfirst Returns the string with its first character converted to lowercase.
  • levenshtein Returns the Levenshtein distance of two strings: the smallest number of single-character insertions, deletions and replacements that turn the first string…
  • localeconv Returns an array with the rules for writing numbers and amounts of money according to the locale set with setlocale(): the decimal point, the thousands…
  • ltrim The ltrim function strips so-called whitespace from the beginning of a string.
  • nl2br Inserts the <br /> tag before every line break in a text.
  • ord Returns the value (0–255) of the first byte of the string $string.
  • pack Builds a binary string from values according to a format, for example numbers as 2 or 4 bytes in a given order.
  • printf Fills values into a format string and prints the result right away.
  • quotemeta Inserts a backslash before each of the characters . \ + * ? [ ^ ] $ ( ) and returns the modified text.
  • rtrim The rtrim function strips so-called whitespace from the end of a string.
  • setlocale Sets the locale that some functions use to sort text, convert letters and format numbers.
  • similar_text Counts how many characters two strings have in common and optionally returns the similarity as a percentage.
  • sprintf Returns a string built from the template $format, into which it fills the other parameters one by one.
  • sscanf Reads values from a string according to a format – it works the opposite way to sprintf().
  • str_contains Checks whether a text contains the searched string and returns true or false.
  • str_decrement Decreases a string by one, the opposite of str_increment(): the last character moves to the previous letter or digit, and on underflow it borrows from…
  • str_ends_with Checks whether a text ends with the given string and returns true or false.
  • str_getcsv Splits one line in CSV format into an array of values.
  • str_increment Increases a string by one just like a counter: the last character moves to the next letter or digit, and on overflow it carries to the left (z → aa, Az…
  • str_ireplace Replaces all occurrences of the searched text with another text and ignores the difference between uppercase and lowercase letters.
  • str_pad Pads the string $string to the length $length by repeating the string $pad_string – on the right, the left or both sides.
  • str_repeat Returns the string repeated as many times in a row as $times says.
  • str_replace Replaces all occurrences of the string $search in the string $subject with the string $replace and returns the result.
  • str_rot13 Replaces every letter of the English alphabet with the letter 13 places further (a → n, n → a).
  • str_shuffle Returns a string with the same characters in random order.
  • str_split Splits a string into an array of parts of equal length.
  • str_starts_with Checks whether a text starts with the given prefix and returns true or false.
  • str_word_count Counts the words in a string, or returns them as an array.
  • strcasecmp Compares two strings just like strcmp(), only it ignores the difference between uppercase and lowercase letters.
  • strcmp Compares two strings byte by byte.
  • strcoll Compares two strings by the sorting rules of the current locale (LC_COLLATE).
  • strcspn Returns the length of the initial part of a text that contains none of the characters of the mask, which is the position of the first such character.
  • strip_tags Removes HTML tags, comments and PHP tags from a text and returns plain text.
  • stripos Returns the position of the first occurrence of the text $needle in the string (counted from zero) and ignores the difference between uppercase and lowercase…
  • stripslashes Removes the backslashes that addslashes() added to a string.
  • stristr Works just like strstr(), only it ignores the difference between uppercase and lowercase letters.
  • strlen Returns the length of the string $string.
  • strnatcasecmp Compares two strings in natural order like strnatcmp(), but ignores the difference between uppercase and lowercase letters.
  • strnatcmp Compares two strings “naturally”, the way a person would sort them: numbers inside the text are treated as numbers, not as single characters.
  • strncasecmp Compares the beginnings of two strings up to the given length and ignores the difference between uppercase and lowercase letters.
  • strncmp Compares two strings like strcmp(), but only up to the given length.
  • strpbrk Finds the first occurrence of any of the given characters in a text and returns the rest of the text from it.
  • strpos Returns the position of the first occurrence of the string $needle in the string $haystack (counted from zero).
  • strrchr Finds the last occurrence of a character in a string and returns the part from it to the end.
  • strrev Returns the string backwards – the last character becomes the first.
  • strripos Returns the position of the last occurrence of the text $needle in the string (counted from zero) and ignores the difference between uppercase and lowercase…
  • strrpos Returns the position of the last occurrence of the text $needle in the string (counted from zero).
  • strspn Returns the length of the initial part of a text made only of the characters listed in the mask.
  • strstr Finds the first occurrence of the text $needle and returns the part of the string from that place to the end.
  • strtok Returns a string part by part.
  • strtolower Returns the string with all letters converted to lowercase. strtoupper() works the other way round.
  • strtoupper Returns the string with all letters converted to uppercase. strtolower() works the other way round.
  • strtr Swaps characters or parts of a text by a translation table.
  • substr Returns the part of the string $string that starts at the position $offset (counted from zero) and has the length $length.
  • substr_compare Compares part of a string from a given position with a second string, without having to cut it out with substr().
  • substr_count Returns how many times the text $needle occurs in the string.
  • substr_replace Replaces part of a string with another text.
  • trim The trim function strips so-called whitespace from the start and the end of a string.
  • ucfirst Returns the string with its first character converted to uppercase.
  • ucwords Returns the string with the first letter of each word converted to uppercase.
  • unpack The opposite of pack(): reads numbers and texts from a binary string according to a format and returns them in an array.
  • vfprintf Works like fprintf(), only it gets the values for the placeholders in one array.
  • vprintf Works like printf(), only it gets the values for the placeholders in one array.
  • vsprintf Works like sprintf(), only it does not get the values as separate parameters but in one array.
  • wordwrap Wraps a text into lines of at most the given width.

Multibyte strings, iconv and intl 49 entries

  • collator_compare Compares two texts by the rules of a language: returns −1 when $a comes before $b, 1 when it comes after it, and 0 when they are equal by the rules.
  • collator_create Creates a Collator object that compares and sorts texts by the alphabet of the given language.
  • collator_sort Sorts an array of texts by the rules of the language from collator_create().
  • datefmt_create Creates an IntlDateFormatter object that prints the date and time by language – with day and month names of the given language (“Friday, October 9, 2026”…
  • datefmt_format Returns a date as text according to the formatter from datefmt_create().
  • grapheme_strlen Returns the number of graphemes – characters as a reader perceives them.
  • grapheme_substr Like mb_substr(), but it counts graphemes – characters as a reader sees them.
  • iconv Converts text from one character encoding to another.
  • iconv_strlen Returns the number of characters of a text, not bytes.
  • iconv_strpos Returns the position of the first occurrence of a text in characters (from 0).
  • iconv_substr Returns part of a text from the given character.
  • idn_to_ascii Converts an internationalized domain (with accents or another script) to the ASCII form with the xn-- prefix, which DNS, mail servers and functions such…
  • idn_to_utf8 The opposite of idn_to_ascii(): converts a domain in the xn--… form back to UTF-8, as the user should see it.
  • mb_check_encoding Checks whether a text is valid in the given encoding.
  • mb_chr Returns the character with the given Unicode number (code point), written in the requested encoding.
  • mb_convert_case Changes the letter case of a text according to the chosen mode.
  • mb_convert_encoding Converts text from one character encoding to another.
  • mb_detect_encoding Tries to determine which of the given encodings a text is in and returns its name.
  • mb_internal_encoding Without a parameter it returns the internal encoding of the mbstring extension, with a parameter it sets it.
  • mb_lcfirst Converts the first character of a string to lowercase and leaves the rest unchanged.
  • mb_ord Returns the Unicode number of the first character of a string, the so-called code point.
  • mb_parse_str Parses a query string (the part of a URL after the question mark) into an array.
  • mb_str_pad Pads a string with a fill to the given number of characters.
  • mb_str_split Splits text into an array of characters, or into parts with the given number of characters.
  • mb_strcut Cuts at most the given number of bytes from a string.
  • mb_strimwidth Shortens text to the given width and adds an ending to the shortened text, usually an ellipsis.
  • mb_stripos Returns the position of the first occurrence of the searched text and ignores the difference between uppercase and lowercase letters, accented letters…
  • mb_stristr Finds the first occurrence of a text regardless of letter case, accented letters included.
  • mb_strlen Returns the number of characters in a string.
  • mb_strpos Returns the position of the first occurrence of the searched text, counted in characters from zero.
  • mb_strrchr Finds the last occurrence of a text and returns the rest of the string from it, or with the third parameter the part before it.
  • mb_strrichr The same as mb_strrchr(), only it ignores the difference between uppercase and lowercase letters, accented letters included.
  • mb_strripos Returns the position of the last occurrence of a text in characters (from 0), regardless of letter case, accented letters included.
  • mb_strrpos Returns the position of the last occurrence of the searched text, counted in characters from zero.
  • mb_strstr Finds the first occurrence of a text and returns the rest of the string from it, or with the third parameter the part before it.
  • mb_strtolower Converts all letters in a text to lowercase, accented letters included.
  • mb_strtoupper Converts all letters in a text to uppercase, accented letters included.
  • mb_strwidth Returns the width of a text displayed in a monospaced font.
  • mb_substr Returns a part of a string just like substr(), but it counts characters, not bytes.
  • mb_substr_count Returns the number of occurrences of the searched text in a string.
  • mb_trim Strips spaces and other whitespace from the start and the end of a text, including the no-break space and other Unicode spaces.
  • mb_ucfirst Converts the first character of a string to uppercase and leaves the rest unchanged.
  • msgfmt_format_message Fills values into a message pattern in the ICU MessageFormat format.
  • normalizer_normalize The same character can be written in Unicode in more ways: “é” as one character, or as “e” followed by a separate accent.
  • numfmt_create Creates a NumberFormatter object that formats numbers by the conventions of a language and country: in English a decimal point and commas between thousands…
  • numfmt_format Returns a number as text by the formatter from numfmt_create().
  • numfmt_format_currency Returns an amount with a currency by the conventions of the formatter locale (the NumberFormatter::CURRENCY style): the order of the number and the sign…
  • numfmt_parse Reads a number from text written by the conventions of a language – with its decimal separator and thousands separators – and returns it as a number.
  • transliterator_transliterate Converts text by ICU rules: it removes accents (Latin-ASCII), writes Cyrillic, Greek or Chinese in Latin letters (Any-Latin), converts to lowercase (Lower()).

Arrays 84 entries

  • array_all Returns true when all elements of the array meet the condition.
  • array_any Returns true when at least one element of the array meets the condition, otherwise false.
  • array_change_key_case Returns a copy of the array in which the string keys are converted to lowercase, or to uppercase.
  • array_chunk Splits an array into smaller arrays with the given number of elements.
  • array_column Picks the values of one column from an array of rows – typically the result of a database query.
  • array_combine Creates a new array: it uses the values of the first array as keys and the values of the second one as values.
  • array_count_values Returns an array whose keys are the individual values of the input array and whose values are the numbers of their occurrences.
  • array_diff Returns the elements of the first array whose value does not occur in any of the other arrays.
  • array_diff_assoc Returns the elements of the first array for which no element with the same key and at the same time the same value exists in the other arrays.
  • array_diff_key Returns the elements of the first array whose key does not occur in any of the other arrays.
  • array_diff_uassoc Does the same as array_diff_assoc(): it returns the elements of the first array that do not have the same key with the same value in the other arrays.
  • array_diff_ukey Does the same as array_diff_key(): it returns the elements of the first array whose key is not in the other arrays.
  • array_fill Creates an array with the given number of elements that all have the same value.
  • array_fill_keys Creates an array whose keys are the values of the first parameter and whose elements all have the same value.
  • array_filter Goes through an array and returns a new array only with the elements for which the given function returns true.
  • array_find Goes through an array and returns the value of the first element for which the condition returns true.
  • array_find_key Goes through an array and returns the key of the first element for which the condition returns true.
  • array_first Returns the value of the first element of an array regardless of its key.
  • array_flip Returns an array with the keys and the values swapped: the values become keys and the keys become values.
  • array_intersect Returns the elements of the first array whose value occurs in all other arrays.
  • array_intersect_assoc Returns the elements of the first array for which every other array has an element with the same key and also the same value.
  • array_intersect_key Returns the elements of the first array whose key appears in all the other arrays.
  • array_intersect_uassoc Does the same as array_intersect_assoc(): returns the elements of the first array that have the same key and value in the other arrays.
  • array_intersect_ukey Does the same as array_intersect_key(): keeps only the elements of the first array whose key is also in all the other arrays.
  • array_is_list Checks whether an array is a list: the keys are 0, 1, 2… without gaps and in this order.
  • array_key_exists Returns true if the array $array contains the key $key, otherwise false.
  • array_key_first Returns the key of the first element of an array.
  • array_key_last Returns the key of the last element of an array.
  • array_keys Returns a new array with all the keys of the given array.
  • array_last Returns the value of the last element of an array regardless of its key.
  • array_map Calls the given function on every element of an array and returns a new array with the results.
  • array_merge Joins one or more arrays into one and returns the result.
  • array_merge_recursive Joins arrays much like array_merge().
  • array_multisort Sorts several arrays at once: by the first array and on a tie by the next ones.
  • array_pad Returns the array padded with the given value to the required length.
  • array_pop Removes the last element from an array and returns its value.
  • array_product Returns the product of all values in an array.
  • array_push Adds one or more values to the end of an array and returns the new number of elements.
  • array_rand Randomly picks one or more keys from an array.
  • array_reduce Walks through an array and with your own function gradually “folds” it into a single value.
  • array_replace Returns the first array with its values replaced by the values under the same key from the other arrays.
  • array_replace_recursive Works like array_replace(), but it also goes into nested arrays: it replaces only the nested values the new arrays contain and leaves the rest.
  • array_reverse Returns a new array with the elements in reverse order.
  • array_search Searches an array and returns the key of the first element whose value equals $needle.
  • array_shift Removes the first element from an array and returns its value.
  • array_slice Returns a slice of an array: the elements from position $offset (counted from zero) of length $length.
  • array_splice Removes a part of an array given by a position and a length and can insert other elements in its place.
  • array_sum Returns the sum of all values in an array.
  • array_udiff Does the same as array_diff(), but compares the values with your own function.
  • array_udiff_assoc Does the same as array_diff_assoc(), but compares the values with your own function.
  • array_udiff_uassoc Combines array_udiff_assoc() and array_diff_uassoc(): returns the elements of the first array that do not have the same key with the same value in the…
  • array_uintersect Does the same as array_intersect(), but compares the values with your own function.
  • array_uintersect_assoc Does the same as array_intersect_assoc(), but compares the values with your own function.
  • array_uintersect_uassoc Combines array_uintersect_assoc() and array_intersect_uassoc(): returns the elements of the first array that have the same key and value in the other arrays.
  • array_unique Returns the array without repeated values.
  • array_unshift Adds one or more values to the start of an array and returns the new number of elements.
  • array_values Returns a new array with all the values of the given array and keys numbered again from zero.
  • array_walk Calls your own function on every element of an array in turn.
  • array_walk_recursive Works like array_walk(), but it also descends into nested arrays.
  • arsort Sorts an array by values in descending order and leaves each value its key.
  • asort Sorts an array by values in ascending order and leaves each value its key.
  • compact Creates an array from existing variables: the key is the name of the variable, the value its content.
  • count Returns the number of elements in the array $array (or in an object that implements the Countable interface).
  • current Returns the value of the element the internal array pointer is on right now.
  • end Sets the internal array pointer to the last element and returns its value.
  • extract Makes a variable out of every element of an array: the key becomes its name, the value its content.
  • in_array Returns true if the array $array contains the value $needle, otherwise false.
  • is_countable Returns true when the value is an array or an object with the Countable interface.
  • is_iterable Returns true when the value is an array or an object with the Traversable interface (iterators and generators).
  • key Returns the key of the element the internal array pointer is on right now.
  • krsort Sorts an array by keys in descending order, the values stay with their keys.
  • ksort Sorts an array by keys in ascending order, the values stay with their keys.
  • natcasesort Sorts an array “naturally” like natsort() – it compares numbers in strings as numbers – and in addition it does not distinguish uppercase and lowercase…
  • natsort Sorts an array “naturally”: it compares numbers inside strings as numbers, so img2 comes before img10.
  • next Moves the internal array pointer one element forward and returns the value of the element it stopped at.
  • prev Moves the internal array pointer one element back and returns the value of the element it stopped at.
  • range Creates an array of values from the start to the end, inclusive.
  • reset Sets the internal array pointer to the first element and returns its value.
  • rsort Sorts an array by values in descending order.
  • shuffle Randomly shuffles the elements of an array.
  • sort Sorts an array by values in ascending order.
  • uasort Sorts an array by values with your own comparison function and leaves each value its key.
  • uksort Sorts an array by keys with your own comparison function, the values stay with their keys.
  • usort Sorts an array by the rule your function defines.

Math 50 entries

  • abs Returns the absolute value of the parameter $num.
  • acos Returns the angle in radians (from 0 to pi) whose cosine is the given number.
  • asin Returns the angle in radians (from -pi/2 to pi/2) whose sine is the given number.
  • atan Returns the angle in radians (from -pi/2 to pi/2) whose tangent is the given number.
  • atan2 Returns the angle between the positive x axis and the point [x, y], in radians from -pi to pi.
  • base_convert Converts the notation of a number from one numeral system to another.
  • bcadd Adds two numbers written as strings and returns the result as a string too.
  • bccomp Compares two numbers written as strings.
  • bcdiv Divides the first number by the second.
  • bcmod Returns the remainder of a division.
  • bcmul Multiplies two numbers.
  • bcpow Raises the base to the exponent.
  • bcpowmod Calculates the remainder of dividing a number raised to an exponent, that is (base to the exponent) mod modulus.
  • bcscale Sets the default number of decimal places for all BCMath functions that do not get it as a parameter.
  • bcsqrt Returns the square root of a number as a string to the given number of decimal places.
  • bcsub Subtracts the second number from the first.
  • bindec Converts a number written in binary (a string of zeros and ones) to an ordinary number.
  • ceil The ceil function returns the nearest integer higher than the number given in the parameter $num.
  • cos Returns the cosine of an angle.
  • decbin Converts an integer to its notation in binary.
  • dechex Converts an integer to its notation in hexadecimal.
  • decoct Converts an integer to its notation in octal.
  • deg2rad Converts an angle from degrees to radians.
  • exp Returns the number e (about 2.718) raised to the given exponent.
  • fdiv Divides two numbers as decimal numbers.
  • floor The floor function returns the nearest lower integer than the one in the parameter $num.
  • fmod Returns the remainder of dividing two numbers, which can be decimal.
  • hexdec Converts a number written in hexadecimal to an ordinary number.
  • hypot Returns the square root of x² + y², that is the length of the hypotenuse of a right triangle or the distance of the point [x, y] from the origin.
  • intdiv Divides two integers and returns the integer quotient without the remainder.
  • is_finite Returns true when a decimal number is an ordinary finite number.
  • is_infinite Returns true when a decimal number is positive or negative infinity (INF, -INF).
  • is_nan Returns true when a decimal number is the special value NAN (“not a number”).
  • log Returns the logarithm of a number.
  • log10 Returns the common (base-10) logarithm of a number, that is to what power ten must be raised to get the given number.
  • max Returns the largest value.
  • min Returns the lowest value.
  • mt_rand Returns a random integer from the Mersenne Twister generator.
  • number_format Formats a number for display – it rounds it to the given number of decimal places and separates the thousands.
  • octdec Converts a number written in the octal system (digits 0–7) to an ordinary number.
  • pi Returns the value of the number pi as a float.
  • pow Returns the base raised to the exponent.
  • rad2deg Converts an angle from radians to degrees.
  • rand Returns a random integer.
  • random_bytes Returns a string of random bytes of the given length.
  • random_int Returns a random integer in the given range including both limits.
  • round Returns the value of the parameter $num rounded according to the parameter $precision (the number of digits after the decimal point).
  • sin Returns the sine of an angle.
  • sqrt Returns the square root of a number, always as a float.
  • tan Returns the tangent of an angle.

Variables and types 24 entries

  • boolval Converts a value to a boolean according to the same rules that apply in an if condition.
  • empty Returns true when the variable does not exist or has an "empty" value: an empty string, "0", 0, 0.0, null, false or an empty array.
  • floatval Converts a value to a float.
  • get_debug_type Returns the type of a value the way it is written in type declarations: int, float, string, bool, null, array, for an object the class name.
  • get_defined_vars Prints all currently defined variables.
  • gettype Returns the name of the type of a value as text: "integer", "double", "string", "boolean", "array", "object", "NULL" or "resource".
  • intval Converts a value to an integer.
  • is_array Returns true when the value is an array.
  • is_bool Returns true when the variable is of the true/false (boolean) type.
  • is_float Returns true when the value is of the float type.
  • is_int Returns true when the variable is of the integer type.
  • is_null Returns true when the value is null.
  • is_numeric Returns true (1) when the variable is a number or a string containing a number.
  • is_object Returns true when the value is an object of any class.
  • is_scalar Returns true for simple (scalar) values: an integer, a float, a string and a boolean.
  • is_string Returns true when the variable contains a string.
  • isset Returns true when the variable (or an array element, an object property) exists and is not null.
  • print_r Prints a value in a readable form: arrays and objects as a structure of keys and values, other values as text.
  • serialize Converts a value to text in the PHP format, from which unserialize() restores it including types and objects.
  • strval Converts a value to a string.
  • unserialize Restores a value (including arrays and objects) from text created by the serialize() function.
  • unset Destroys a variable, an array element or an object property.
  • var_dump Prints the type and value of one or more variables, for arrays and objects the whole structure.
  • var_export Prints a value as valid PHP code that can be pasted back into a script.

Classes, functions and constants 25 entries

  • call_user_func Calls a function passed as a value (a name, an anonymous function, a pair [object, method]) with further parameters and returns its result.
  • call_user_func_array Calls a function and passes it the parameters from an array.
  • class_alias Creates another name for an existing class.
  • class_exists Returns true when a class with the given name exists.
  • constant Returns the value of a constant whose name is stored in a string.
  • define Creates a constant – a named value that cannot be changed and is available everywhere in the script, even inside functions.
  • defined Returns true when a constant with the given name exists.
  • func_get_arg Inside a function it returns the argument at the given position (from 0), even if the function does not have it among its parameters.
  • func_get_args Inside a function it returns an array of all parameters it was called with, including those the function does not declare.
  • func_num_args Inside a function it returns how many arguments were actually passed to it, including extra ones.
  • function_exists Returns true when a function with the given name exists – built-in, from an extension or your own.
  • get_called_class Returns the name of the class through which the method was called (late static binding).
  • get_class Returns the name of the class the object is an instance of.
  • get_class_methods Returns an array of the method names of a class, including inherited and static ones.
  • get_class_vars Returns an array of class properties with their default values from the declaration, including static ones.
  • get_defined_constants Returns an array of all defined constants (name => value), built-in and custom ones.
  • get_object_vars Returns an array of the properties of an object, including their values.
  • get_parent_class Returns the name of the class the given class directly inherits from.
  • interface_exists Returns true when an interface with the given name is defined.
  • is_a Returns true when the object is an instance of the given class, of its descendant, or of a class that implements the given interface.
  • is_callable Returns true when the value can be called: the name of an existing function, a closure, a pair [object, method] or the text “Class::method”.
  • is_subclass_of Returns true when the object or class inherits from the given class (also across several levels) or implements the given interface.
  • method_exists Returns true when the class (given by an object or by name) has a method with the given name.
  • property_exists Returns true when the class or object has a property with the given name, even when its value is null or it is private.
  • trait_exists Returns true when a trait with the given name is defined.

Date and time 40 entries

  • cal_days_in_month Returns the number of days in the given month and year.
  • checkdate Returns true when the date exists in the Gregorian calendar – it takes into account the number of days in a month and leap years.
  • date Formats a local date/time.
  • date_add Adds an interval (a DateInterval object) to a DateTime object and returns the modified object.
  • date_create Creates a DateTime object from a text with a date and time (in the same formats as strtotime()).
  • date_create_from_format Creates a DateTime object from a text whose format you describe exactly, for example “j.n.Y” for a European date with dots.
  • date_create_immutable Creates a DateTimeImmutable object from a text with a date.
  • date_create_immutable_from_format Reads a date from a text according to the given format and returns an immutable DateTimeImmutable object, or false.
  • date_date_set Sets a new date of a DateTime object and leaves the time unchanged.
  • date_default_timezone_get Returns the name of the default time zone used by the date and time functions.
  • date_default_timezone_set Sets the default time zone the functions date(), mktime(), strtotime() and the DateTime class use to convert timestamps to dates and back.
  • date_diff Calculates the difference between two DateTime objects.
  • date_format Returns the date and time from a DateTime object as text in the given format.
  • date_interval_format Outputs a DateInterval object (for example the result of date_diff()) according to a format.
  • date_isodate_set Sets the date of a DateTime object by an ISO 8601 week: the year, the week number and the day of the week (1 = Monday … 7 = Sunday).
  • date_modify Changes a DateTime object by a text in the same form that strtotime() accepts: “+1 day”, “next monday”, “first day of next month”.
  • date_offset_get Returns the offset of the time zone of the object from UTC in seconds, valid for its date and time.
  • date_parse Splits a text with a date and time into an array of parts (year, month, day, hour, minute, second, fraction) and adds the counts and texts of errors and…
  • date_sub Subtracts an interval (a DateInterval object) from a DateTime object and returns the modified object.
  • date_time_set Sets a new time of a DateTime object and leaves the date.
  • date_timestamp_get Returns the Unix timestamp (the number of seconds since 1 January 1970 00:00 UTC) of a DateTime or DateTimeImmutable object.
  • date_timestamp_set Sets the moment of a DateTime object from a Unix timestamp.
  • date_timezone_get Returns the time zone of a DateTime or DateTimeImmutable object as a DateTimeZone object.
  • date_timezone_set Converts a DateTime object to another time zone.
  • easter_date Returns the number of seconds corresponding to midnight at the start of Easter in the given year.
  • easter_days Returns the number of days between 21 March and Easter Sunday of the given year.
  • getdate Returns an array with the parts of a date and time for the given timestamp (without a parameter for the current time): seconds, minutes, hours, day, day…
  • gettimeofday Returns the current time with microsecond precision.
  • gmdate Works like date(), but outputs the time in UTC (Greenwich Mean Time), not in the configured time zone.
  • microtime Returns the current time with microseconds.
  • mktime Returns the timestamp (the number of seconds since 1 January 1970) for the given date and time in the configured time zone.
  • strftime Formats a date and time according to a format with the characters %d, %m, %Y… and according to the configured locale (for example with French month names).
  • strtotime Converts an English text description of a date and time to a timestamp (the number of seconds since 1 January 1970).
  • time The time function returns an integer giving the number of seconds elapsed since 1 January 1970, the so-called Unix epoch.It has no parameters.
  • timezone_identifiers_list Returns an alphabetical list of time zone names (Europe/Prague, America/New_York…).
  • timezone_location_get Returns an array with data from the time zone database: country_code, latitude and longitude (the coordinates of the place the zone is named after) and…
  • timezone_name_get Returns the name of the time zone: the name from the database (Europe/Prague), the offset (+02:00) or the abbreviation (CET), depending on how the zone…
  • timezone_offset_get Returns the offset of the time zone from UTC in seconds that applies in it at the moment of the given date.
  • timezone_open Creates a DateTimeZone object that is passed to the date and time functions.
  • timezone_transitions_get Returns an array of the transitions of a zone, such as the changes between winter and summer time.

Files and directories 66 entries

  • basename Returns the last part of a path (the name of a file or folder).
  • chdir Changes the working folder of the script.
  • chmod Sets the permissions of a file or folder and returns true, on error false with a warning.
  • clearstatcache During a script PHP remembers information about files (size, times, existence).
  • closedir Closes a folder opened with opendir() and frees the system resource.
  • copy Copies a file to a new location and returns true, on error false with a warning.
  • dir Opens a folder and returns a Directory object.
  • dirname Returns the path without its last part, that is the parent folder.
  • fclose Closes a file opened with fopen() and returns true.
  • feof Returns true when reading from the file has tried to go past its end.
  • fflush Sends the data waiting in the stream buffer to its target (a file, network connection, program).
  • fgetc Reads one byte from an open file and moves the pointer.
  • fgetcsv Reads one CSV record from an open file and returns an array of values.
  • fgets Reads one line from a file including the line break character.
  • file Reads the whole file and returns an array in which each line is one element (including the line break character).
  • file_exists Returns true when a file or folder exists at the given path.
  • file_get_contents Reads the whole file (or a part of it) and returns the content as a string.
  • file_put_contents Writes data to a file and returns the number of bytes written, on error false.
  • fileatime Returns the time of the last access (read) of a file as a Unix timestamp.
  • filectime Returns a timestamp whose meaning depends on the system: on Linux it is the time of the last change of the file information (inode), on Windows the time…
  • filemtime Returns the time of the last change of the file content as a timestamp (the number of seconds since 1 Jan 1970), on error false.
  • fileperms Returns a number with the file type and permissions (the same as stat()["mode"]).
  • filesize Returns the size of a file in bytes, on error false with a warning.
  • filetype Returns the type of the entry as text: file, dir (folder), link (symbolic link), or fifo, char, block, socket or unknown.
  • finfo_buffer Detects the type of the data in a string by its content and returns it as text (MIME type, encoding or description, depending on the flags from finfo_open()).
  • finfo_close Frees the resource created by finfo_open() and returns true.
  • finfo_file Finds information about a file by its content: MIME type, encoding or description.
  • finfo_open Prepares the detection of file types by their content (the fileinfo extension, the libmagic library).
  • flock Locks or unlocks an open file.
  • fopen Opens a file (or a URL) and returns a handle that fgets(), fwrite() and other functions work with.
  • fpassthru Outputs the content of an open file from the current position to the end and returns the number of bytes output.
  • fputcsv Writes the values of an array as one CSV line and returns the length of the written line, on error false.
  • fread Reads at most $length bytes from a file and returns them as a string.
  • fscanf Reads one line from an open file and parses it by a format like sscanf().
  • fseek Moves the pointer in an open file, the next read or write then starts at the new position.
  • fstat Returns an array with information about an open file (size, mtime, mode…), the same as stat() for a file given by its name.
  • ftell Returns the position of the pointer in an open file, that is the number of bytes from the start.
  • fwrite Writes text to a file opened with fopen() and returns the number of bytes written, on error false. fputs() works the same way.
  • get_include_path Returns the current value of the include_path setting: a list of folders in which include, require and some file functions look for files given by a relative…
  • getcwd Returns the path to the current working folder, from which relative paths are calculated.
  • glob Returns an array of paths to the files and folders that match the pattern.
  • is_dir Returns true when the path leads to an existing folder.
  • is_executable Returns true when the file exists and is executable.
  • is_file Returns true when the path leads to an existing regular file.
  • is_readable Returns true when the file or folder exists and PHP has permission to read it.
  • is_writable Returns true when the file or folder exists and PHP may write to it.
  • mime_content_type Detects the content type of a file (MIME, for example image/png) by its first bytes, not by the extension.
  • mkdir Creates a folder and returns true, on failure false with a warning.
  • opendir Opens a folder and returns a handle from which readdir() reads the names of entries one by one.
  • parse_ini_file Loads a file in the INI format (key = value, sections in [square brackets]) and returns an array.
  • parse_ini_string Parses text in the INI format into an array, just like parse_ini_file() does with a file.
  • pathinfo Returns an array with the keys dirname (folder), basename (name), extension and filename (name without the extension).
  • readdir Returns the name of the next entry from a folder opened with opendir().
  • readfile Reads a file and prints it to the output without loading all of it into memory.
  • realpath Returns the full absolute path: it resolves “.” and “..”, removes extra slashes and replaces links (symlinks) with the real path.
  • rename Renames or moves a file or folder and returns true, on failure false with a warning.
  • rewind Moves the pointer of an open file to the start.
  • rmdir Deletes an empty folder and returns true.
  • scandir Returns an array of the names of all entries in a folder (files and subfolders) including “.” and “..”, sorted alphabetically.
  • set_include_path Sets include_path for the running script and returns the original value, or false on failure.
  • stat Returns an array with information about a file or folder: size, atime, mtime, ctime (times), mode (type and permissions), uid, gid (owner) and more.
  • sys_get_temp_dir Returns the path to the folder for temporary files without a trailing slash. tmpfile() and tempnam() use it.
  • tempnam Creates an empty file with a unique name in the given folder and returns the path to it, on failure false.
  • tmpfile Creates a new file with a unique name in the folder for temporary files and opens it for reading and writing.
  • touch When the file does not exist, it creates it empty.
  • unlink Deletes a file and returns true, on failure false with a warning.

HTTP, URLs and sessions 41 entries

  • filter_has_var Returns true when the request to the server contained a parameter with the given name.
  • filter_input Reads a value from the original request data and validates it with a filter.
  • filter_input_array Validates several values from $_GET, $_POST or cookies at once by a definition of filters.
  • filter_var Validates a value by the chosen filter – for example whether it is an email, an integer or a URL.
  • filter_var_array Validates the values in an array by a definition of filters and returns an array of results: the validated value, false on failure, null for a missing…
  • get_headers Sends a request to the URL and returns an array of the response headers, on failure false.
  • get_meta_tags Reads an HTML page from a file or a URL and returns an array of its <meta name="…" content="…"> tags in the head.
  • header Sends an HTTP response header to the browser.
  • header_remove Removes a response header that has not been sent yet.
  • headers_list Returns an array of the response headers that the script set with header(), setcookie() and other functions, in the form "Name: value".
  • headers_sent Returns true when the headers have already been sent and neither header() nor setcookie() will send anything.
  • http_build_query Builds a string of parameters from an array for a URL or for data sent with the POST method.
  • http_response_code With the parameter it sets the status code of the response and returns the previous code.
  • ip2long Converts an IPv4 address in dotted notation to an integer.
  • is_uploaded_file Returns true when the file was uploaded by a form in the current request (the path from $_FILES["…"]["tmp_name"]).
  • long2ip Converts a number (0 to 4,294,967,295) to an IPv4 address in the usual notation, for example 192.168.1.1.
  • mail Hands an email over to the mail program of the server.
  • move_uploaded_file Moves a file uploaded by a form from the temporary folder to its destination.
  • parse_str Parses a string of parameters in the form found after the question mark in a URL and stores them in an array in the second parameter.
  • parse_url Splits a URL into parts and returns them in an array: scheme, host, port, user, pass, path, query, fragment.
  • rawurldecode Converts the %XX notation back to the original bytes.
  • rawurlencode Encodes text for use in a URL according to RFC 3986.
  • session_abort Closes the active session without saving: changes in $_SESSION since session_start() are discarded and the original data stay in the storage.
  • session_cache_expire Returns the time in minutes that PHP sends in the cache headers (Expires, max-age) for pages with a session.
  • session_cache_limiter Returns the setting by which session_start() sends cache headers.
  • session_destroy Deletes the data of the running session on the server and returns true.
  • session_get_cookie_params Returns an array with the settings of the cookie in which the browser carries the session identifier: lifetime, path, domain, secure, httponly and samesite.
  • session_id Without the parameter it returns the identifier of the current session, or an empty string when no session is running.
  • session_name Returns the session name, which is used as the cookie name (PHPSESSID by default).
  • session_regenerate_id Creates a new ID for the running session, keeps the data in $_SESSION and sends a new cookie to the browser.
  • session_reset Loads the session data from the storage again and overwrites $_SESSION with them.
  • session_save_path Returns the folder where PHP stores session files (session.save_path).
  • session_set_cookie_params Sets the parameters of the cookie that carries the session ID.
  • session_start Starts a new session, or resumes an existing one based on the cookie from the browser.
  • session_status Returns the session status: PHP_SESSION_DISABLED (0) sessions are disabled, PHP_SESSION_NONE (1) no session is active, PHP_SESSION_ACTIVE (2) a session…
  • session_unset Removes all variables from the $_SESSION array.
  • session_write_close Saves the data from $_SESSION and ends the session in the current script, which releases its lock.
  • setcookie Sends the browser a header that stores a cookie.
  • setrawcookie Sends a cookie to the browser just like setcookie(), only it does not encode the value.
  • urldecode Converts text encoded for a URL back: %XX sequences into the original bytes and the plus sign into a space.
  • urlencode Encodes text for use in a URL as a parameter value after the question mark.

Hashes, passwords and encryption 40 entries

  • crc32 Returns the CRC32 checksum of a text as an integer (always positive on 64-bit PHP).
  • crypt Calculates a one-way hash of a text.
  • hash Calculates a checksum of a text with a chosen algorithm and returns it in hexadecimal. hash_algos() returns the list of available algorithms.
  • hash_equals Returns true when both strings are the same.
  • hash_file Calculates a checksum of the file contents with a chosen algorithm.
  • hash_hmac Calculates a signature (HMAC) of data with a chosen algorithm and a secret key.
  • hash_hmac_file Calculates an HMAC signature of the file contents with the given secret key, just like hash_hmac() does for text.
  • hash_pbkdf2 Derives a key from a password according to the PBKDF2 standard: a salted hash is calculated the given number of times so that trying passwords takes a…
  • md5 Returns the MD5 checksum of a text as 32 hexadecimal characters.
  • md5_file Returns the MD5 checksum of the file contents as 32 hexadecimal characters, or false on failure.
  • openssl_cipher_iv_length Returns how many bytes the initialization vector should have for the given cipher.
  • openssl_decrypt Decrypts data with the same cipher, key and IV that were used for encryption (with GCM also with the authentication tag).
  • openssl_digest Calculates a hash of data with an algorithm of the OpenSSL library.
  • openssl_encrypt Encrypts data with a chosen cipher and key.
  • openssl_error_string Returns the oldest error message from the error queue of the OpenSSL library and removes it from the queue, or false when the queue is empty.
  • openssl_get_cipher_methods Returns an array of the names of ciphers that the OpenSSL library on the server supports (aes-256-gcm, chacha20-poly1305…).
  • openssl_pkey_export Writes a private key into a variable as text in the PEM format (-----BEGIN PRIVATE KEY-----).
  • openssl_pkey_get_details Returns an array with details of the key: bits (the length), type (OPENSSL_KEYTYPE_RSA, …_EC…), key (the public key in PEM format) and details by type…
  • openssl_pkey_new Generates a new key pair – a private and a public key.
  • openssl_random_pseudo_bytes Returns the given number of cryptographically random bytes.
  • openssl_sign Creates a digital signature of data with a private key.
  • openssl_verify Verifies that the signature matches the data and the public key.
  • password_algos Returns an array of the algorithm identifiers for password_hash() that PHP supports on the given server: always "2y" (bcrypt), and depending on the PHP…
  • password_get_info Returns an array with the keys algo (the algorithm identifier), algoName (the name) and options (options such as cost).
  • password_hash Creates a hash from a password that is suitable for storing in a database.
  • password_needs_rehash Returns true when the hash was created with a different algorithm or with different options than the given ones.
  • password_verify Returns true when the password matches a hash created with password_hash() (or crypt()).
  • sha1 Returns the SHA-1 checksum of a text as 40 hexadecimal characters.
  • sha1_file Returns the SHA-1 checksum of the file contents as 40 hexadecimal characters, or false on failure.
  • sodium_crypto_pwhash_str Creates a password hash with the Argon2id algorithm, including a random salt and the parameters in one string (it starts with $argon2id$).
  • sodium_crypto_pwhash_str_verify Returns true when the password matches the hash, otherwise false.
  • sodium_crypto_secretbox Encrypts a message with a secret key and attaches an authentication code – decryption with sodium_crypto_secretbox_open() detects that someone has tampered…
  • sodium_crypto_secretbox_keygen Returns a new random 32-byte key for sodium_crypto_secretbox().
  • sodium_crypto_secretbox_open Verifies the authentication code and decrypts the data.
  • sodium_crypto_sign_detached Signs a message with a private key and returns the signature alone (64 bytes); the data stays unchanged.
  • sodium_crypto_sign_keypair Generates a key pair for signatures with the Ed25519 algorithm – fast and short signatures, with nothing to configure.
  • sodium_crypto_sign_publickey Returns the public key (32 bytes) from a key pair.
  • sodium_crypto_sign_secretkey Returns the private key (64 bytes) from a pair created by sodium_crypto_sign_keypair().
  • sodium_crypto_sign_verify_detached Returns true when the signature belongs to the message and to the public key, otherwise false.
  • sodium_memzero Overwrites the contents of a string in memory with zeros and sets the variable to null.

Regular expressions, JSON and ctype 24 entries

  • ctype_alnum Returns true when the string contains only letters and digits and is not empty.
  • ctype_alpha Returns true when the string contains only letters according to the current locale and is not empty.
  • ctype_digit Returns true when the string contains only the digits 0–9 and is not empty.
  • ctype_lower Returns true when the string contains only lowercase letters (a–z in the default locale) and is not empty.
  • ctype_print Returns true when the string contains only printable characters and is not empty.
  • ctype_punct Returns true when the string contains only punctuation characters, that is printable characters that are not a letter, a digit or a space.
  • ctype_space Returns true when the string contains only whitespace characters: a space, a tab, a line break (\n, \r), a vertical tab and a form feed.
  • ctype_upper Returns true when the string contains only uppercase letters (A–Z in the default locale) and is not empty.
  • ctype_xdigit Returns true when the string contains only the hexadecimal digits 0–9, a–f and A–F and is not empty.
  • json_decode Converts a string in JSON format into a PHP value.
  • json_encode Converts a value (most often an array or an object) into a string in JSON format.
  • json_last_error Returns the error code of the last call to json_decode() or json_encode().
  • json_last_error_msg Returns an English description of the error of the last call to json_decode() or json_encode().
  • json_validate Checks that a string is valid JSON and returns true or false.
  • preg_filter Works the same as preg_replace(), but for an array it returns only the elements where it found a match.
  • preg_grep Returns the elements of an array that match a regular expression.
  • preg_last_error Returns the error code of the last call to a preg_* function.
  • preg_match Finds out whether a string matches a regular expression.
  • preg_match_all Finds all occurrences of a regular expression in a string, returns their number and stores the matches in an array.
  • preg_quote Adds a backslash before the characters that have a special meaning in a regular expression (.\+*?[^]$(){}=!<>|:-#).
  • preg_replace Finds all parts of a string that match a regular expression and replaces them.
  • preg_replace_callback Finds the matches of a regular expression and replaces each one with what the given function returns.
  • preg_replace_callback_array Receives an array where the key is a regular expression and the value a function that returns the replacement.
  • preg_split Splits a string wherever the regular expression matches and returns an array of the parts.

Output and errors 23 entries

  • assert Checks an assumption that should always hold in the code.
  • debug_backtrace Returns an array of the steps through which the program got to the current place.
  • debug_print_backtrace Prints the chain of calls (backtrace): which functions were called, from where and with which arguments, up to the place where the function stands.
  • error_clear_last Clears the record of the last error message.
  • error_get_last Returns the last PHP error message (warning, notice…) as an array with the keys type, message, file and line.
  • error_log Writes a message to the PHP error log or to your own file, or sends it by e-mail.
  • error_reporting Sets which kinds of errors PHP reports and returns the previous setting.
  • flush Sends the output that PHP is holding so far to the web server (Apache, FastCGI), which can then send it to the browser.
  • ob_clean Clears what is in the output buffer so far (since ob_start()).
  • ob_end_clean Discards the content of the current output buffer and ends the buffer.
  • ob_end_flush Sends the content of the current output buffer (to the parent buffer, or to the browser) and ends the buffer.
  • ob_flush Sends the content of the output buffer one level up (to the parent buffer, or to the output) and empties the buffer.
  • ob_get_clean Returns the content of the current output buffer as a string and ends the buffer without sending the content.
  • ob_get_contents Returns the content of the current output buffer, but leaves the buffer on and the content stays in it.
  • ob_get_flush Returns the content of the output buffer as a string, at the same time sends it one level up (prints it) and turns the buffer off.
  • ob_get_length Returns the number of bytes that are in the output buffer so far.
  • ob_get_level Returns how many output buffers are currently active one inside another.
  • ob_start Turns on the output buffer: everything the script prints (echo, HTML outside <?php) is stored in the buffer instead of being sent to the browser.
  • register_shutdown_function Registers a function that runs after the script ends – after the last line, after exit, after a fatal error and after an uncaught exception.
  • restore_error_handler Removes the error handler set by the last set_error_handler() and restores the previous one.
  • set_error_handler Sets a function that PHP calls instead of its own error reporting (warnings, notices, deprecations).
  • set_exception_handler Sets a function that receives an exception that no try/catch block caught anywhere.
  • trigger_error Raises an error with your own message.

System and script execution 29 entries

  • escapeshellarg Encloses a string in quotes so that the shell takes it as a single argument, even if it contains spaces, semicolons or quotes.
  • escapeshellcmd Before characters with a special meaning in the shell (; & | < > ` $ and others) it adds a backslash on Linux and a caret ^ on Windows.
  • exec Runs an operating system command.
  • extension_loaded Returns true when the PHP extension with the given name is loaded.
  • get_current_user Returns the name of the owner of the running script file.
  • get_loaded_extensions Returns an array of the names of loaded PHP extensions (Core, date, pcre, mbstring…).
  • getenv Returns the value of an environment variable, or false when it does not exist.
  • gethostname Returns the name of the computer (server) PHP runs on.
  • getopt Reads the options the script was started with from the command line (php script.php -v --file=data.csv) and returns them as an array.
  • hrtime Returns the time of the system monotonic clock: an array [seconds, nanoseconds], with true a single integer in nanoseconds.
  • ini_get Returns the current value of a PHP setting as a string.
  • ini_set Changes a PHP setting only for the running script and returns the original value as a string.
  • memory_get_peak_usage Returns the highest number of bytes of memory the script has used since it started.
  • memory_get_usage Returns the number of bytes of memory the script is using at that moment.
  • passthru Runs an operating system command and sends its output unchanged to the output of the script.
  • php_sapi_name Returns the name of the interface PHP runs through: “cli” on the command line, “apache2handler” as an Apache module, “fpm-fcgi” under PHP-FPM, “cgi-fcgi”…
  • php_uname Returns information about the operating system PHP runs on: without a parameter the full description, with a parameter only part of it.
  • phpinfo Prints detailed information about PHP: the version, settings from php.ini, loaded extensions, environment and server variables.
  • phpversion Returns the PHP version as a string, for example “7.4.33”.
  • putenv Sets an environment variable written as "NAME=value".
  • set_time_limit Sets the longest time the script may run and at the same time restarts the counter from zero.
  • shell_exec Runs an operating system command and returns its whole output as one text, including line endings.
  • sleep Pauses the script for the given number of whole seconds.
  • system Runs an operating system command, prints its output straight away (to the browser) and returns the last line.
  • time_nanosleep Pauses the script for the given time: whole seconds plus nanoseconds.
  • time_sleep_until Pauses the script until the given moment (a timestamp with a decimal part, as returned by microtime(true)).
  • uniqid Returns an identifier derived from the current time in microseconds.
  • usleep Pauses the script for the given number of microseconds (millionths of a second).
  • version_compare Compares two version numbers part by part.

cURL 12 entries

  • curl_close In PHP 7 it closes a cURL handle and frees its memory.
  • curl_copy_handle Creates a new cURL handle with the same options as the given one (address, headers, time limits…).
  • curl_errno Returns the error number of the last cURL request, 0 = no error.
  • curl_error Returns the error text of the last request (unreachable server, timeout, certificate error).
  • curl_exec Sends a request according to the options set.
  • curl_file_create Creates a CURLFile object that goes into the array for CURLOPT_POSTFIELDS. cURL then sends the file as a form attachment (multipart/form-data).
  • curl_getinfo Returns details of the last request: without the second parameter an array of all details, with a CURLINFO_* constant only one detail.
  • curl_init Creates a cURL handle through which HTTP requests are sent to other servers (APIs, downloading pages).
  • curl_reset Resets all options of a cURL handle to their defaults, as after curl_init() without an address.
  • curl_setopt Sets one option of a cURL handle – the address, the method, headers, a time limit.
  • curl_setopt_array Sets several options of a cURL handle at once from an array CURLOPT_* => value.
  • curl_version Returns an array with details of the libcurl library PHP uses: version, protocols (supported protocols), ssl_version (the encryption library), features…

Images – GD and EXIF 33 entries

  • exif_imagetype Reads the beginning of the file and by the format signature returns the image type as an IMAGETYPE_* constant (IMAGETYPE_JPEG, IMAGETYPE_PNG…), or false…
  • exif_read_data Reads EXIF data from a JPEG (and TIFF) image that a camera or a phone wrote into the file: make and model, date taken, rotation, exposure, often a GPS…
  • getimagesize Returns an array with the width, height, image type and MIME type.
  • image_type_to_mime_type Converts a numeric image type – the IMAGETYPE_* constants returned by getimagesize() and exif_imagetype() – to a MIME type, for example image/jpeg.
  • imagealphablending Decides what happens when you draw with a semi-transparent colour: with blending on (the default for true colour images) the colour is mixed with what…
  • imagecolorallocate Returns a colour identifier that the drawing functions need (imagefill, imageline, imagestring…).
  • imagecolorallocatealpha Like imagecolorallocate(), but with transparency.
  • imagecolorat Returns the colour of the pixel at the coordinates $x, $y (counted from the top left corner from 0).
  • imagecopy Copies a rectangle $width × $height from the source image to the given place in the destination, at the original size.
  • imagecopyresampled Copies a rectangle from the source to the destination and recalculates it to another size with smoothing (resampling).
  • imagecreatefromjpeg Loads a JPEG image and returns it as a GD image that the other image… functions work with – shrinking, cropping, a watermark.
  • imagecreatefrompng Loads a PNG image – a logo, an icon, a screenshot.
  • imagecreatefromstring Creates an image from binary data in a string, not from a file.
  • imagecreatefromwebp Loads an image in the WebP format – smaller files than JPEG and PNG at the same quality, with transparency.
  • imagecreatetruecolor Creates a new image of the given size in full colour (16.7 million colours and transparency).
  • imagecrop Returns a new image with the crop given by an array x, y, width, height.
  • imagedestroy In PHP 7 it freed the memory of a GD image.
  • imagefill Fills the connected area of the same colour in which the point $x, $y lies (like the “bucket” in paint programs).
  • imagefilledrectangle Fills the rectangle between the top left corner $x1, $y1 and the bottom right one $x2, $y2.
  • imagefilter Modifies the whole image with a filter – converts it to greyscale, changes the brightness or contrast, blurs it, highlights edges.
  • imageflip Flips the image in place (it does not return a new one): mirrored from left to right, from top to bottom, or both (which is the same as rotating by 180°).
  • imagejpeg Saves the image in the JPEG format – to a file, or without a file (null) straight to the output, for example as a response to the browser.
  • imageline Draws a straight line from the point $x1, $y1 to the point $x2, $y2.
  • imagepng Saves the image as PNG – losslessly, with transparency (with imagesavealpha).
  • imagerectangle Draws the outline of a rectangle – a line 1 point wide, wider according to imagesetthickness().
  • imagerotate Returns a new image rotated by an angle in degrees counter-clockwise.
  • imagesavealpha Tells GD to keep full transparency (the alpha channel) when saving to PNG (and WebP).
  • imagescale Returns a new image in the given size; the original stays unchanged.
  • imagestring Writes a single line of text with a built-in bitmap font.
  • imagesx Returns the width of a loaded or created GD image in pixels.
  • imagesy Returns the height of a GD image in pixels.
  • imagettftext Writes text with a font from a TTF or OTF file – with accented letters (UTF-8), smoothing, in any size and rotated.
  • imagewebp Saves the image in the WebP format.

Databases – mysqli 28 entries

  • mysqli_affected_rows Returns the number of rows the last query on the connection inserted, changed or deleted.
  • mysqli_begin_transaction Starts a transaction: the following queries take effect in the database only after mysqli_commit(), or they are all cancelled via mysqli_rollback().
  • mysqli_close Closes the connection to the database server and frees it for other clients.
  • mysqli_commit Commits the running transaction: all its changes are written for good and other connections see them too.
  • mysqli_connect Opens a connection to a MySQL or MariaDB database server and selects a database.
  • mysqli_connect_errno Returns the error number of the last mysqli_connect() call, or 0 when the connection succeeded.
  • mysqli_connect_error Returns the error text of the last mysqli_connect() call, or null when the connection succeeded.
  • mysqli_error Returns the error text of the last call on the connection (a query, selecting a database…), or an empty string when there was no error.
  • mysqli_execute_query Combines mysqli_prepare(), passing the values, mysqli_stmt_execute() and mysqli_stmt_get_result() into one call.
  • mysqli_fetch_all Returns all (remaining) rows of the result as an array of rows.
  • mysqli_fetch_array Returns the next row of the result – in the default mode with both numeric indexes and column names (every value is in the array twice).
  • mysqli_fetch_assoc Returns the next row of the result as an associative array (the keys are the column names), or null when there is no further row.
  • mysqli_fetch_row Returns the next row of the result as an array with the indexes 0, 1, 2… in the order of the query columns, or null when there is no further row.
  • mysqli_free_result Frees the memory taken by a query result.
  • mysqli_insert_id Returns the AUTO_INCREMENT column value the last INSERT on this connection created – for example the number of a new order to which the items are then…
  • mysqli_num_rows Returns the number of rows in the result of a SELECT query.
  • mysqli_prepare Sends the server a query with question marks instead of values (WHERE id = ?).
  • mysqli_query Runs an SQL query.
  • mysqli_real_escape_string Adds backslashes before characters that have a special meaning in an SQL string (the apostrophe, quotes, the backslash, the line end, the null byte), according…
  • mysqli_report Decides what happens on a connection or query error.
  • mysqli_rollback Cancels all changes of the running transaction, as if the queries had never run.
  • mysqli_set_charset Sets the character set in which PHP and the database server send each other texts.
  • mysqli_stmt_bind_param Binds variables to the question marks of a prepared statement – in the order in which the question marks appear.
  • mysqli_stmt_bind_result Binds the result columns to variables in the order of the columns in SELECT.
  • mysqli_stmt_close Closes a prepared statement on the server and in PHP.
  • mysqli_stmt_execute Runs a prepared statement with the values the variables bound via mysqli_stmt_bind_param() have at that moment.
  • mysqli_stmt_fetch Writes the next row of the result into the variables bound via mysqli_stmt_bind_result().
  • mysqli_stmt_get_result After mysqli_stmt_execute() it returns the result of a SELECT as a mysqli_result object – the same as from mysqli_query(), so the rows are read by mysqli_fetch_assoc()…

XML 14 entries

  • libxml_clear_errors Empties the list of errors that libxml_get_errors() returns.
  • libxml_get_errors Returns an array of LibXMLError objects with the errors stored since the last libxml_clear_errors().
  • libxml_use_internal_errors With true, errors from loading XML and HTML (SimpleXML, DOM, XMLReader) stop printing warnings and go into a list returned by libxml_get_errors().
  • simplexml_import_dom Returns a SimpleXMLElement over the same document as the given DOM node – both views share the data, so a change in one shows in the other.
  • simplexml_load_file Like simplexml_load_string(), but it loads the XML from a file or URL (with allow_url_fopen enabled).
  • simplexml_load_string Loads XML from text and returns a SimpleXMLElement object: nested elements are properties ($xml->product->name), attributes are array items ($product["id"])…
  • xml_error_string Returns the English description of the error for a number from xml_get_error_code(), such as “Mismatched tag” or “Invalid character”.
  • xml_get_error_code Returns the number of the last parser error, or 0 if no error occurred.
  • xml_parse Processes a part of the XML and calls the functions that have been set.
  • xml_parse_into_struct Processes the whole XML and writes a flat array into $values: each item has a tag, type (open, complete, close), level, and possibly attributes and value.
  • xml_parser_create Creates a parser that does not keep the whole XML in memory but, while reading, calls your functions for each element start, element end and text (xml_set_element_handler()…
  • xml_parser_free In PHP 7 it freed the parser and its memory.
  • xml_set_character_data_handler Sets the function the parser calls with the text inside elements.
  • xml_set_element_handler Sets two functions: the parser calls the first at the start of each element (with the name and an array of attributes) and the second at its end.