Built-in functions

305 functions compiled into the language, generated from the compiler's own table and documented by hand. PHP names wherever PHP has them — if you know PHP, you already know this library.

Strings (65)

Everything around byte strings: searching, cutting, comparing, padding, formatting and escaping. Strings are byte-oriented (UTF-8 text passes through untouched, but length/count are bytes).

strlen(mixed $v): int
Length of a string in bytes (not characters). For arrays use count().
strtoupper(string $s): string
Converts every ASCII letter in the string to uppercase.
strtolower(string $s): string
Converts every ASCII letter in the string to lowercase.
ucfirst(string $s): string
Uppercases the first character of the string, leaves the rest untouched.
lcfirst(string $s): string
Lowercases the first character of the string, leaves the rest untouched.
trim(string $s): string
Strips leading and trailing whitespace (space, tab, newline, CR, NUL).
ltrim(...$args): string
Strips leading whitespace only. Optional second argument: character list to strip.
rtrim(...$args): string
Strips trailing whitespace only. Alias: chop(). Optional second argument: character list.
strrev(string $s): string
Reverses the string byte by byte.
str_repeat(int $times, string $s): string
Repeats the string n times: str_repeat("ab", 3) -> "ababab".
str_pad(...$args): string
Pads the string to the given length with a pad string (default " "), repeated on the right.
str_replace(...$args): string
str_replace($search, $replace, $subject) — replaces every occurrence of $search in $subject.
substr(...$args): string
substr($s, $start[, $len]) — extracts up to $len bytes starting at $start. Negative $start counts from the end; omitted $len means "to the end".
strstr(string $haystack, string $needle): string
Returns the part of $haystack from the first occurrence of $needle to the end, or false if not found.
strchr(string $haystack, string $needle): string
Alias of strstr().
strpos(...$args): mixed
Byte position of the first occurrence of $needle in $haystack, or false when absent. Use !== false to test.
str_contains(string $haystack, string $needle): bool
true when $needle occurs anywhere in $haystack (PHP 8 style, no position needed).
str_starts_with(string $haystack, string $needle): bool
true when $haystack begins with $needle.
str_ends_with(string $haystack, string $needle): bool
true when $haystack ends with $needle.
strcmp(string $a, string $b): int
Byte-wise comparison: returns < 0, 0, or > 0 as $a sorts before, equal to, or after $b.
strncmp(...$args): int
Like strcmp() but compares at most the first n bytes (third argument).
strncasecmp(...$args): int
Case-insensitive strncmp(): first n bytes, returns -1/0/1 style result.
strcasecmp(string $a, string $b): int
Case-insensitive strcmp().
explode(string $haystack, string $needle): mixed
explode($separator, $s) - splits the string at every separator into an array. The separator cannot be empty.
implode(...$args): string
Joins array elements with a glue string: implode($glue, $arr) or implode($arr).
join(...$args): string
Alias of implode().
nl2br(string $s): string
Inserts "<br />" before every newline. Newlines are kept.
number_format(...$args): string
Formats a number with grouped thousands: number_format($n[, $decimals[, $dec_point, $thousands_sep]]). Defaults: 0 decimals, ".", ",".
password_hash(string $s): string
Creates a salted password hash ($hphp$4096$salt$digest, PBKDF2-SHA256, 4096 rounds). Store this string; never store plain passwords.
password_verify(string $haystack, string $needle): bool
password_verify($plain, $hash) — recomputes the digest with the hash's salt and compares timing-safely. true when the password matches.
strtotime(string $s): int
Parses a date/time string ("2024-03-15 12:30:00", "2024-03-15", "12:30:00") into a Unix timestamp; 0 on failure.
parse_url(string $s): mixed
parse_url($url) — map with scheme, user, host, port, path, query, fragment; missing parts are empty strings, port defaults to 80/443.
urlencode(string $s): string
Encodes a string for use in a query string: space becomes +, reserved chars become %XX.
urldecode(string $s): string
Inverse of urlencode().
htmlentities(string $s): string
Converts & " ' < > (and more) to their HTML entities so the string is safe to embed as text.
htmlspecialchars(string $s): string
Converts only the five HTML-critical characters & " ' < > to entities.
sprintf(...$args): string
printf-style formatting that returns the string. Supports %d %s %f %x %o %b %e %c, width, precision and "-" left-align.
printf(...$args): int
Like sprintf() but prints the result and returns its length.
vsprintf(...$args): string
sprintf() with the arguments taken from an array.
ord(string $s): int
Byte value of the first character of the string (0–255).
chr(int $n): string
One-character string for the given byte value.
bin2hex(string $s): string
Hexadecimal representation of the bytes, two chars per byte: bin2hex("AB") → "4142".
hex2bin(string $s): string
Decodes a hexadecimal string back into raw bytes.
str_split(...$args): mixed
str_split($s[, $len]) - cuts the string into chunks of $len characters (default 1) and returns them as an array.
ucwords(string $s): string
Uppercases the first letter of every whitespace-separated word.
wordwrap(...$args): string
Wraps a string to a given width by inserting breaks (default "\n") at word boundaries.
similar_text(string $haystack, string $needle): int
Number of matching characters between the two strings (a rough similarity measure).
levenshtein(string $haystack, string $needle): int
Edit distance (insertions, deletions, substitutions) between the two strings.
substr_count(string $haystack, string $needle): int
Counts how many times $needle occurs in $haystack.
str_shuffle(string $s): string
Randomly shuffles the characters of the string (not cryptographically secure).
strip_tags(...$args): string
Removes HTML and PHP tags from the string.
html_entity_decode(string $s): string
Inverse of htmlentities(): "&amp;" becomes "&" again.
is_string(mixed $number): bool
true when the value is a string.
strval(mixed $number): string
Converts the value to its string representation.
stream_socket_server(...$args): mixed
stream_socket_server("host:port") — binds and listens on a TCP socket; returns a server handle (or -1).
stream_socket_client(...$args): mixed
stream_socket_client("host:port") — connects to a TCP server; returns a socket handle (or -1).
stream_socket_accept(...$args): mixed
Accepts one incoming connection from a server handle (blocks until a client arrives).
stream_socket_accept2(...$args): mixed
Like stream_socket_accept() but with a timeout in milliseconds.
stream_set_blocking(...$args): bool
Switches a socket handle between blocking and non-blocking mode.
stream_ready(...$args): mixed
Checks which of the given socket handles are readable (select-style); returns the ready handles as an array.
stream_recv(...$args): string
stream_recv($sock[, $max]) — receives up to $max bytes (default 4096) from the socket as a string.
stream_send(...$args): int
stream_send($sock, $data) — sends the string over the socket; returns the bytes sent.
stream_eof(...$args): bool
true when the peer closed the connection.
stream_peer(...$args): string
IP:port of the remote end of the socket.
stream_close(...$args): bool
Closes a socket handle.

Regex (5)

PCRE-style pattern matching on the built-in backtracking engine. Patterns use /.../ delimiters with trailing flags i, s, m; \d \w \s classes, captures and alternation are supported. A bad pattern returns false, it does not throw.

preg_match(...$args): mixed
preg_match($pattern, $subject[, &$matches]) — tries the pattern once on $subject. Returns 1 and fills $matches (index 0 = full match, 1..n = capture groups) on success, false on no match or bad pattern. Patterns use /.../ delimiters with flags i (case-insensitive), s (dotall), m (multiline).
preg_match_all(...$args): mixed
preg_match_all($pattern, $subject[, &$matches]) — finds every non-overlapping match. Returns the number of matches and fills $matches with one array per match (each like preg_match's $matches).
preg_replace(...$args): string
preg_replace($pattern, $replacement, $subject) — replaces every match. $replacement may reference captures as $1, $2, … Returns the modified string.
preg_split(...$args): mixed
preg_split($pattern, $subject) — splits $subject at every match of the pattern and returns the pieces as an array.
preg_grep(...$args): mixed
preg_grep($pattern, $array) — returns the elements of $array that match the pattern (keys are re-indexed 0..n).

Arrays (50)

One array type covers lists and maps (string keys allowed). The in-place sorts (sort, ksort, usort, …) modify the array and return true. Closures passed to map/filter/reduce/walk/usort are normal fn() closures.

count(mixed $v): int
Number of elements in an array, or length of a string. Aliased by sizeof().
sizeof(mixed $v): int
Alias of count(): elements in an array, bytes in a string.
array(...$values): mixed
Creates an array from the given values (or "key" => value pairs). Usually written as the [...] literal instead.
array_keys(array $a): mixed
Returns all keys of the array as a new list array.
array_values(array $a): mixed
Returns all values of the array as a freshly indexed list (0..n-1).
array_merge(...$args): mixed
Merges two or more arrays; later arrays overwrite string keys of earlier ones, numeric keys are appended.
array_slice(...$args): mixed
array_slice($arr, $offset[, $length]) — extracts a section of the array. Negative $offset counts from the end.
array_reverse(array $a): mixed
Returns the array with elements in reverse order.
array_sum(...$args): mixed
Sum of all numeric values in the array (non-numerics count as 0).
array_product(...$args): mixed
Product of all numeric values in the array.
array_unique(array $a): mixed
Removes duplicate values, keeping the first occurrence of each.
in_array(...$args): bool
in_array($needle, $haystack) — true when the value occurs in the array.
array_key_exists(...$args): bool
true when $key exists in the array (also for string keys and null values).
range(int $start, int $end): mixed
range($start, $end) — list of integers from $start to $end inclusive (also counts down).
compact(...$args): mixed
Builds an array from the named local variables: compact("a", "b") → ["a" => $a, "b" => $b].
array_column(...$args): mixed
array_column($rows, $col) — picks one column out of an array of maps, indexed 0..n.
array_chunk(...$args): mixed
array_chunk($arr, $size) — splits the array into chunks of at most $size elements.
array_pad(...$args): mixed
array_pad($arr, $size, $value) — grows the array to $size by filling with $value (negative size pads left).
array_replace(...$args): mixed
array_replace($a, $b, …) — elements of later arrays overwrite those of earlier ones, keys preserved.
array_fill_keys(...$args): mixed
array_fill_keys(["a","b"], $v) — map with those keys, each mapped to $v.
array_key_first(...$args): mixed
First key of the array (null when empty).
array_key_last(...$args): mixed
Last key of the array (null when empty).
usort(...$args): bool
usort($arr, $cmp) — sorts by value in place using a comparator closure returning -1/0/1.
uasort(...$args): bool
usort with key association preserved (for maps).
uksort(...$args): bool
Sorts the map in place by key using a comparator closure.
array_walk(...$args): bool
array_walk($arr, $fn) — calls $fn($value, $key) for every element; the closure may modify $value via a by-ref parameter.
array_walk_recursive(...$args): bool
Like array_walk() but descends into nested arrays.
array_map(...$args): mixed
array_map($fn, $arr[, $arr2, …]) — applies the closure to every element and returns the results. With several arrays the closure gets one argument per array.
array_filter(...$args): mixed
array_filter($arr[, $fn]) — keeps elements where $fn returns true; without $fn keeps all truthy elements. Keys are preserved.
array_reduce(...$args): mixed
array_reduce($arr, $fn[, $initial]) — folds the array left-to-right: $fn($carry, $item).
array_flip(array $a): mixed
Swaps keys and values: ["a" => 1] becomes [1 => "a"].
array_fill(...$args): mixed
array_fill($start, $num, $value) — $num copies of $value starting at index $start.
array_combine(...$args): mixed
array_combine($keys, $values) — builds a map using one array as keys and the other as values.
array_diff(...$args): mixed
array_diff($a, $b, …) — values of $a that do not appear in any other array.
array_intersect(...$args): mixed
array_intersect($a, $b, …) — values of $a that appear in all other arrays.
array_push(...$args): int
Appends one or more values to the end of the array; returns the new count. $arr[] = v is preferred.
array_pop(...$args): mixed
Removes and returns the last element of the array (null when empty).
array_shift(...$args): mixed
Removes and returns the first element, re-indexing the rest (null when empty).
array_unshift(...$args): int
Prepends one or more values to the front of the array; returns the new count.
array_splice(...$args): mixed
array_splice($arr, $offset[, $length[, $replacement]]) — removes a section and optionally replaces it; returns the removed elements.
shuffle(...$args): bool
Randomly reorders the array in place (not cryptographically secure).
sort(array &$a): bool
Sorts the array in place by value, ascending, re-indexing 0..n.
rsort(array &$a): bool
Sorts the array in place by value, descending, re-indexing.
ksort(array &$a): bool
Sorts the map in place by key, ascending, keeping key/value association.
krsort(array &$a): bool
Sorts the map in place by key, descending.
asort(array &$a): bool
Sorts the map in place by value, ascending, keeping key/value association.
end(...$args): mixed
Advances the internal pointer to the last element and returns its value.
reset(...$args): mixed
Rewinds the internal pointer to the first element and returns its value.
is_array(mixed $number): bool
true when the value is an array or map.

Math (35)

Arithmetic helpers, trigonometry (radians!), rounding with PHP_ROUND_HALF_* modes, and randomness. rand()/mt_rand() are fine for games and shuffling; use random_int()/random_bytes() for anything security-related.

random_bytes(int $n): string
random_bytes($n) — $n cryptographically secure random bytes as a raw binary string (max 1024).
max(...$numbers): mixed
Largest of the given numbers or array elements (variadic).
min(...$numbers): mixed
Smallest of the given numbers or array elements (variadic).
rand(...$args): int
rand() → pseudo-random int, or rand($min, $max) within the inclusive range (not secure).
mt_rand(...$args): float
Mersenne-Twister pseudo-random: mt_rand() or mt_rand($min, $max) (faster, still not secure).
srand(...$args): void
Seeds rand() — only useful to get reproducible sequences.
mt_srand(...$args): void
Seeds mt_rand() — only useful to get reproducible sequences.
random_int(...$args): int
Cryptographically secure random integer in [$min, $max]. Prefer this over rand().
abs(mixed $number): mixed
Absolute value; keeps the input type (int stays int, float stays float).
round(...$args): mixed
round($n[, $precision[, $mode]]) — rounds to $precision decimals (default 0). $mode: PHP_ROUND_HALF_UP (default), _HALF_DOWN, _HALF_EVEN, _HALF_ODD.
floor(mixed $number): float
Largest integer value ≤ $n, returned as float.
ceil(mixed $number): float
Smallest integer value ≥ $n, returned as float.
sqrt(mixed $number): float
Square root as float.
pow(...$args): mixed
pow($base, $exp) — $base raised to $exp.
intdiv(...$args): int
Integer division truncating toward zero: intdiv(7, 2) === 3.
fmod(...$args): float
Floating-point remainder of $x / $y.
sin(mixed $number): float
Sine of the angle in radians.
cos(mixed $number): float
Cosine of the angle in radians.
tan(mixed $number): float
Tangent of the angle in radians.
atan(mixed $number): float
Arctangent in radians.
atan2(mixed $number): float
Angle of the point (y, x) — note the argument order.
asin(mixed $number): float
Arcsine in radians.
acos(mixed $number): float
Arccosine in radians.
log(mixed $number): float
Natural logarithm (ln). Optional second argument is the base.
log2(mixed $number): float
Binary logarithm (base 2).
log10(mixed $number): float
Common logarithm (base 10).
exp(mixed $number): float
e raised to the given power.
is_nan(mixed $number): bool
true for the special Not-a-Number float value.
is_finite(mixed $number): bool
true when the float is neither infinite nor NaN.
is_infinite(mixed $number): bool
true for ±infinity.
pi(...$args): float
Returns π as float. The constant M_PI is equivalent.
deg2rad(mixed $number): float
Converts degrees to radians.
rad2deg(mixed $number): float
Converts radians to degrees.
hypot(...$args): float
hypot($a, $b) — length of the hypotenuse sqrt(a² + b²), overflow-safe.
lcg_value(...$args): float
Pseudo-random float in [0, 1) from the combined linear congruential generator (not secure).

Types & vars (24)

Introspection and conversion. var_dump() is your debugging friend. The compiler also checks types statically — these functions matter at runtime when values arrive untyped (JSON, user input, mixed params).

unset(...$args): void
unset($arr["k"]) removes the key from the array; unset($var) is not needed for locals.
json_encode(...$args): string
Encodes a value as JSON. Flags: JSON_PRETTY_PRINT (indented), JSON_UNESCAPED_SLASHES (keep /), JSON_NUMERIC_CHECK, JSON_FORCE_OBJECT. Combine with |.
json_encode_pretty(string $s): string
json_encode() with JSON_PRETTY_PRINT pre-applied — convenience wrapper.
json_decode(string $s): mixed
Decodes a JSON string into arrays/maps/scalars. Optional second argument ($assoc) is accepted for PHP compatibility and ignored.
isset(...$args): bool
isset($arr["k"]) — true when the key exists and the value is not null.
is_int(mixed $number): bool
true when the value is an integer. Aliases: is_integer().
is_integer(mixed $number): bool
Alias of is_int().
is_float(mixed $number): bool
true when the value is a float.
is_bool(mixed $number): bool
true when the value is true or false.
is_null(mixed $number): bool
true when the value is null.
is_numeric(mixed $number): bool
true when the value is a number or a numeric string like "42" or "3.5".
intval(mixed $number): int
Converts to int, truncating floats and parsing the leading integer of strings (0 when not numeric).
floatval(mixed $number): float
Converts to float. Alias: doubleval().
boolval(mixed $number): bool
Converts to bool using PHP truthiness (0, "", "0", [], null are false).
gettype(mixed $number): string
Type name as a string: "int", "float", "string", "bool", "array", "null", …
var_dump(...$args): void
Prints type and value of one or more expressions, recursively for arrays — the main debugging tool.
print_r(...$args): string
Human-readable dump of a value (arrays indented). Returns the text instead of printing it.
var_export(...$args): string
Returns a string of PHP code that would recreate the value.
serialize(mixed $number): string
Serializes the value into a storable string (HolyPHP's own format — do not exchange with PHP's).
unserialize(mixed $number): mixed
Restores a value serialized by serialize(). Never unserialize untrusted input.
is_dir(string $s): bool
true when the path is an existing directory.
is_file(string $s): bool
true when the path is an existing regular file.
is_readable(string $s): bool
true when the file exists and can be read.
is_writable(string $s): bool
true when the file exists and can be written.

Time (10)

Unix timestamps are the base (int seconds since 1970). date() formats them, strtotime()/mktime() build them, hrtime() measures with nanosecond precision for benchmarks. exit/die live here because they end the program like a clock would end a party.

mktime(...$args): int
mktime($h, $m, $s, $month, $day, $year) — builds a Unix timestamp from local date/time parts.
checkdate(...$args): bool
checkdate($month, $day, $year) — true when the date is a valid calendar date (knows leap years).
microtime(...$args): float
Current time as float seconds with microsecond precision (e.g. 1691234567.1234).
hrtime(...$args): int
High-resolution monotonic counter in nanoseconds — use for benchmarking, immune to clock changes.
date(...$args): string
date($format[, $timestamp]) — formats the timestamp (default: now) according to $format. Supported: Y y m n d j H G i s a A D l M N W t L U.
time(...$args): int
Current Unix timestamp — seconds since 1970-01-01 UTC.
usleep(int $n): void
Pauses the program for the given number of microseconds.
sleep(int $n): int
Pauses the program for the given number of seconds.
exit(...$args): void
Terminates the program immediately with the given exit code (default 0). Alias: die().
die(...$args): void
Alias of exit().

System & I/O (39)

Files (whole-file helpers plus fopen-style streaming), directories, process environment and external commands. The stream_* family is the raw TCP layer the registry server and WebSocket library are built on.

fgetc(...$args): string
Reads a single character from a file handle.
readline(string $s): string
Prints the prompt and reads one line from stdin (for interactive scripts).
file_get_contents(string $s): string
Reads an entire file into a string. Throws when the file cannot be opened.
file_put_contents(...$args): int
file_put_contents($path, $data[, $flags]) — writes the string/binary data to the file. Flag PHP_FILE_APPEND appends instead of truncating.
file_exists(string $s): bool
true when a file or directory exists at the path.
filesize(string $s): int
Size of the file in bytes.
mkdir(...$args): bool
mkdir($path[, $recursive]) — creates a directory; with $recursive true it creates parents too.
rmdir(string $s): bool
Removes an (empty) directory.
rename(string $haystack, string $needle): bool
Renames or moves a file (also across directories).
copy(string $haystack, string $needle): bool
Copies the file's contents to a new path.
fgets(string $s): string
Reads one line (up to and including the newline) from a file handle. Returns false at end of file.
fwrite(string $haystack, string $needle): int
fwrite($handle, $data) — writes the data; returns the number of bytes written.
fopen(string $haystack, string $needle): mixed
fopen($path, $mode) — opens a file handle for streaming ("r" read, "w" truncate+write, "a" append, "rb"/"wb" binary).
fclose(string $s): bool
Closes a file handle opened by fopen(). Always do this for written files.
scandir(string $s): mixed
Lists the entries of a directory as an array (including "." and "..").
dirname(string $s): string
Directory part of a path: dirname("a/b/c.txt") → "a/b".
basename(...$args): string
File name part of a path: basename("a/b/c.txt") → "c.txt". Optional second argument strips a suffix.
pathinfo(...$args): mixed
pathinfo($path) — map with dirname, basename, extension and filename.
realpath(string $s): mixed
Resolves relative parts and returns the canonical absolute path (false when it does not exist).
touch(string $s): bool
Creates the file if missing, otherwise updates its modification time.
sys_get_temp_dir(): string
Path of the system's temporary directory.
fread(...$args): string
fread($handle, $max) — reads up to $max bytes from a file handle.
feof(...$args): bool
true when the file handle has reached end of file.
getcwd(): string
Current working directory of the process.
bindec(string $s): int
Parses a binary string ("1010") into an integer.
octdec(string $s): int
Parses an octal string ("777") into an integer.
hexdec(string $s): int
Parses a hexadecimal string ("ff") into an integer.
getenv(string $s): string
Value of the environment variable (empty string when unset).
putenv(string $s): bool
putenv("NAME=value") — sets an environment variable for this process.
php_uname(...$args): string
Operating system description string, e.g. "Windows NT …".
phpversion(...$args): string
Version of the HolyPHP runtime (duplicate entry kept for lookup stability).
php_sapi_name(...$args): string
Interface name — "cli" for command line builds.
memory_get_usage(...$args): int
Bytes currently allocated by the runtime's heap.
memory_get_peak_usage(...$args): int
Largest amount of memory the process has used so far.
gc_collect_cycles(...$args): int
Forces a garbage-collection pass; returns the number of freed objects.
sys_getloadavg(...$args): mixed
System load average as an array (platform-dependent, mostly informational).
php_logo_guid(...$args): string
Returns the logo identifier (kept for PHP-compat novelty; safe to ignore).
php_sapi(...$args): string
Alias of php_sapi_name().

HTTP & MySQL (10)

A small HTTP client (http:// only — no TLS in the runtime) and a native MySQL/MariaDB wire-protocol client. http_get/post return ["status", "body", "contentType"] maps or false on failure; mysql_query returns rows as maps.

http_post(...$args): mixed
http_post($url, $body[, $headers]) — HTTP POST with the body string and optional header lines (e.g. "Content-Type: application/json"). Same return shape as http_get().
http_build_query(string $s): string
Turns a map into an urlencoded query string: ["a" => "x y"] → "a=x+y".
mysql_connect(...$args): mixed
mysql_connect($host[, $port[, $user[, $pass[, $db]]]]) — opens a MySQL/MariaDB connection (native wire protocol, TCP). Returns a connection handle or false.
mysql_query(...$args): mixed
mysql_query($conn, $sql) — runs a SELECT/SHOW and returns the rows as an array of maps (column name => value), false on error. For INSERT/UPDATE/DELETE use mysql_exec().
mysql_exec(...$args): mixed
mysql_exec($conn, $sql) — runs a statement and returns the number of affected rows, false on error.
mysql_insert_id(...$args): int
AUTO_INCREMENT value generated by the last INSERT on this connection.
mysql_close(...$args): bool
Closes the MySQL connection.
mysql_escape(string $s): string
Escapes a string for safe embedding in SQL text (see the crypto group entry).
http_get(string $s): mixed
http_get($url) — performs an HTTP GET (http:// only, no TLS) and returns ["status" => 200, "body" => …, "contentType" => …], or false on failure.
http_request(...$args): mixed
http_request($url, $method, $body, $headers) — generic HTTP request for custom verbs (PUT, DELETE, …).

Hash & encode (8)

Checksums (crc32, md5, sha1 — legacy), real hashes (sha256), keyed signatures (hash_hmac) and password storage (password_hash/verify, PBKDF2-SHA256). Rule of thumb: password_hash for logins, sha256 for everything else, hash_equals for comparing secrets.

sha256(string $s): string
SHA-256 hash as 64-char hex. The general-purpose hash of this runtime.
hash_hmac(...$args): mixed
hash_hmac("sha256", $data, $key) — keyed HMAC-SHA256 for signing messages.
hash_equals(string $haystack, string $needle): bool
Timing-safe string comparison for verifying hashes/signatures — always use it for secrets instead of ===.
md5(...$args): string
MD5 hash as 32-char hex. Fast but broken for security — checksums only.
sha1(...$args): string
SHA-1 hash as 40-char hex. Also legacy — prefer sha256().
crc32(string $s): int
CRC-32 checksum of the data as an integer — detects accidental corruption, not tampering.
base64_encode(string $s): string
Encodes bytes as Base64 text (with = padding) — for safe transport in JSON, URLs-after-urlencode, etc.
base64_decode(string $s): string
Decodes Base64 back to raw bytes. Invalid characters are skipped.

UI (desktop) (44)

Native desktop windows (Win32) with buttons, inputs, lists, menus, timers and dialogs — no external dependencies. Build the UI, register ui_on() callbacks, then call ui_run_main() to enter the event loop. Control kinds for ui_add(): 1 window, 2 button, 3 label, 4 input, 5 checkbox, 6 list, 7 combo, 8 progress, 9 slider, 10 group, 11 tab, 12 panel, 13 menu, 14 menuitem, 15 picture.

ui_dispatch(int $n): int
Runs one iteration of the UI event loop (for manual/embedded loops). Prefer ui_run_main().
ui_run_main(): void
Starts the UI event loop — call once after building your windows; blocks until the last window closes.
ui_quit(): void
Ends the UI event loop and closes the application.
ui_window(...$args): int
ui_window($title, $x, $y, $w, $h) — creates a window; returns its handle.
ui_show(...$args): int
ui_show($handle, $visible) — shows or hides a window/control.
ui_title(...$args): int
Sets the window title.
ui_size(...$args): int
ui_size($handle, $w, $h) — resizes a window/control.
ui_pos(...$args): int
ui_pos($handle, $x, $y) — moves a window/control.
ui_close(...$args): int
Destroys a window/control handle.
ui_alive(...$args): bool
true while the window/event loop is still running.
ui_add(...$args): int
ui_add($parent, $kind, $text, $x, $y, $w, $h) — adds a control to a window. $kind: 1=window 2=button 3=label 4=input 5=checkbox 6=list 7=combo 8=progress 9=slider 10=group 11=tab 12=panel 13=menu 14=menuitem 15=picture. Returns the control handle.
ui_set(...$args): int
Sets the text of a control (label, button, input value, …).
ui_get(...$args): string
Reads the current text/value of a control (e.g. an input field).
ui_enable(...$args): int
ui_enable($handle, $enabled) — enables/disables a control.
ui_move(...$args): int
Moves a control inside its parent.
ui_focus(...$args): int
Gives the keyboard focus to a control.
ui_items(...$args): int
Number of items in a list/combo control.
ui_remove(...$args): int
ui_remove($handle, $index) — removes an item from a list/combo.
ui_clear(...$args): int
Removes all items from a list/combo (or text from an input).
ui_ctrl_show(...$args): int
Shows/hides a single control.
ui_selected(...$args): int
Index of the selected item in a list/combo (-1 when none).
ui_select(...$args): int
ui_select($handle, $index) — selects an item programmatically.
ui_item_text(...$args): string
Text of the item at the given index.
ui_check_get(...$args): int
true when a checkbox is checked.
ui_check_set(...$args): int
ui_check_set($handle, $checked) — sets a checkbox.
ui_progress(...$args): int
ui_progress($handle, $percent) — sets a progress bar (0–100).
ui_slider_get(...$args): int
Current value of a slider.
ui_slider_set(...$args): int
Sets a slider's value.
ui_bg(...$args): int
ui_bg($handle, $color) — background color (RGB int, e.g. 0xFF0000 for red).
ui_fg(...$args): int
Foreground (text) color as RGB int.
ui_font(...$args): int
ui_font($handle, $size[, $bold[, $italic[, $family]]]) — sets a control's font.
ui_menu(...$args): int
Creates a menu bar / menu for a window.
ui_menu_item(...$args): int
Appends an item to a menu; returns its handle (for ui_on callbacks).
ui_menu_sep(...$args): int
Appends a separator line to a menu.
ui_menu_check(...$args): int
ui_menu_check($handle, $checked) — checkable menu item state.
ui_on(...$args): int
ui_on($handle, $event, $callback) — registers a closure for events: "click", "change", "select", "close", … The closure receives event-specific arguments.
ui_timer(...$args): int
ui_timer($ms, $callback) — runs the closure every $ms milliseconds until ui_quit().
ui_msg(...$args): int
ui_msg($win, $title, $text[, $type]) — message box. $type: 0=info 1=warning 2=error 3=question.
ui_open_file(...$args): mixed
Opens the platform file-open dialog; returns the chosen path or false.
ui_save_file(...$args): mixed
Opens the platform save-file dialog; returns the chosen path or false.
ui_pick_folder(...$args): mixed
Folder-picker dialog; returns the path or false.
ui_pick_color(...$args): mixed
Color-picker dialog; returns the RGB int or false.
ui_clip_set(string $s): int
Copies text to the system clipboard.
ui_clip_get(): string
Reads text from the system clipboard.

Unsafe / FFI (6)

Escape hatches to raw memory and native shared libraries. Every one of these requires an unsafe { } block in the compiler — with intent: this is where memory bugs live.

free(...$args): void unsafe
unsafe: frees a raw pointer obtained from FFI. Wrong use corrupts memory — this is why it needs an unsafe block.
memcpy(...$args): mixed unsafe
unsafe: copies $n bytes from one raw address to another.
memset(...$args): mixed unsafe
unsafe: fills $n bytes at an address with a byte value.
ffi_load(string $s): mixed unsafe
unsafe: ffi_load("mylib.dll") — loads a shared library for direct native calls. Returns a library handle or false.
ffi_call(...$args): mixed unsafe
unsafe: ffi_call($lib, "symbol") — resolves an exported function in a loaded library; call the result with the documented signature.
heap_dump(...$args): string unsafe
Returns a debug dump of the runtime heap (allocation count, sizes).

Other (9)

chop(string $s): string
Alias of rtrim(): strips trailing whitespace.
split(string $haystack, string $needle): mixed
Alias of explode().
M_PI(...$args): float
The constant π as a callable fallback — prefer the constant.
doubleval(mixed $number): float
Alias of floatval().
glob(string $s): mixed
glob($pattern) - file paths matching a shell wildcard pattern ("*.hphp", "src/*/*.c") as an array.
decbin(int $n): string
Integer to binary string: decbin(10) -> "1010".
decoct(int $n): string
Integer to octal string: decoct(8) -> "10".
dechex(int $n): string
Integer to hexadecimal string: dechex(255) -> "ff".
malloc(int $n): mixed unsafe
unsafe: allocates n bytes of raw memory; returns a pointer for memcpy/memset/ffi. Must be freed with free().

Predefined constants (14)

Compile-time constants, usable anywhere a value is expected (not callable).

PHP_INT_SIZE : int
8 — bytes per int on this build.
PHP_INT_MAX : int
9223372036854775807 — largest integer.
PHP_INT_MIN : int
-9223372036854775808 — smallest integer.
PHP_EOL : string
Platform line ending (\r\n on Windows).
PHP_OS : string
Operating system family ("Windows").
PHP_VERSION : string
HolyPHP runtime version.
PHP_PI / PHP_EULER / PHP_FLOAT_EPSILON : float
π, e, and the float epsilon.
PHP_ROUND_HALF_UP / _DOWN / _EVEN / _ODD : int
Mode flags for round().
PHP_FILE_APPEND : int
Flag for file_put_contents(): append instead of truncate.
PHP_FILE_IGNORE_NEW_LINES / PHP_FILE_SKIP_EMPTY_LINES / PHP_FILE_USE_INCLUDE_PATH : int
Flags for file()/file() style helpers.
JSON_PRETTY_PRINT : int
json_encode() flag: multi-line indented output.
JSON_UNESCAPED_SLASHES : int
json_encode() flag: keep / unescaped.
JSON_NUMERIC_CHECK : int
json_encode() flag: numeric strings become numbers.
JSON_FORCE_OBJECT : int
json_encode() flag: empty arrays become {}.