Documentation

elephc docs

Everything about elephc — from PHP syntax support to compiler-specific extensions and internal architecture.

Getting Started

Install elephc and compile your first program.

How-To

Task-oriented guides for building real programs with elephc.

Compiling

Command-line flags, the compilation pipeline, targets, optimization, and diagnostics.

PHP Syntax

Standard PHP features supported by elephc. All PHP syntax is 100% compatible with the PHP interpreter.

Builtins

Index of all PHP builtins supported by Elephc.

Types

Data types supported by elephc: int, float, string, bool, array, null, mixed, iterable, resource, callable, object, enum, and extension types.

Operators

Arithmetic, comparison, logical, bitwise, string, assignment, ternary, null coalescing, and error-control operators.

Control Structures

if/else, while, for, foreach, switch, match, try/catch, and more.

Functions

Function declarations, closures, arrow functions, variadic parameters, and more.

Strings

String types, escape sequences, interpolation, heredoc/nowdoc, and built-in string functions.

Regex

PCRE2-backed regular expressions, preg_* functions, SPL regex iterators, and native library requirements.

Arrays

Indexed arrays, associative arrays, copy-on-write, and built-in array functions.

Math

Mathematical functions: abs, floor, ceil, round, clamp, trigonometry, logarithms, and more.

Classes

Classes, interfaces, abstract classes, traits, enums, properties, and inheritance.

SPL

Standard PHP Library interfaces, exceptions, and runtime-backed container classes.

Namespaces

Namespace declarations, use imports, name resolution, include/require.

System & I/O

System functions, date/time, JSON, filesystem utilities, process execution, and debugging utilities.

Streams

Stream resources, wrappers, contexts, filters, sockets, TLS, and process pipes.

Magic Constants

PHP magic constants (__DIR__, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, __NAMESPACE__, __TRAIT__) resolved at compile time to plain string or integer literals.

Fibers

Cooperative coroutines (PHP 8.1+ Fiber): create, start, suspend, resume, with FiberError.

Generators

Generator functions with yield, the built-in Iterator and Generator types, foreach over Iterator objects, and Generator::send for coroutine-style flow.

PDO (Databases)

PDO database access with the SQLite, PostgreSQL, and MySQL/MariaDB drivers: connections, prepared statements, fetch modes, and transactions.

Date and Time

Built-in DateTime, DateTimeImmutable, DateTimeZone, and DateInterval classes for working with dates and time intervals.

Images

GD image creation and I/O, plus the always-available image info functions, backed by a pure-Rust codec bridge.

Calendar

The ext/calendar functions: Julian Day conversions for the Gregorian, Julian, French Republican and Jewish calendars, plus Easter and calendar metadata.

String builtins

Builtins in the String category.

Array builtins

Builtins in the Array category.

Math builtins

Builtins in the Math category.

Type builtins

Builtins in the Type category.

JSON builtins

Builtins in the JSON category.

Regex builtins

Builtins in the Regex category.

Date builtins

Builtins in the Date category.

IO builtins

Builtins in the IO category.

Filesystem builtins

Builtins in the Filesystem category.

Streams builtins

Builtins in the Streams category.

Process builtins

Builtins in the Process category.

SPL builtins

Builtins in the SPL category.

Class builtins

Builtins in the Class category.

Pointer builtins

Builtins in the Pointer category.

Buffer builtins

Builtins in the Buffer category.

Misc builtins

Builtins in the Misc category.

Beyond PHP

Compiler-specific extensions that go beyond standard PHP.

Compiler Internals

How elephc works under the hood — from lexing to ARM64 code generation.