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.

Eval

Experimental PHP eval support, including literal AOT lowering, dynamic interpreter fallback, scope synchronization, safety, and limitations.

Strings

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

Regex

PCRE2-backed regular expressions, preg_* functions, SPL regex iterators, and the managed pcre2 package.

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.

Sessions

PHP session functions for persistent state across HTTP requests under --web.

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.

cURL

PHP's ext/curl on pinned libcurl 8.21.0 with HTTP/2, 25 protocols, OpenSSL, and native iOS SecTrust: easy, multi and share interfaces, uploads, callbacks, and documented PHP differences.

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.

mysqli (MySQL / MariaDB)

The mysqli subset: connections, buffered queries and results, prepared statements, multi_query, mysqli_report error handling, and the documented divergences from php-src.

PDO (Databases)

PDO database access with SQLite, PostgreSQL, MySQL/MariaDB, optional PDO_DBLIB, PDO_FIREBIRD, PDO_ODBC, PDO_INFORMIX, PDO_IBM, PDO_SQLSRV, PDO_OCI, and PDO_CUBRID: connections, prepared statements, fetch modes, transactions, and php-src divergences.

Calendar

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

OPcache

The observable Zend OPcache API emulated over elephc's compile-time script manifest.

PHP Compatibility

How much of PHP elephc covers: functions, classes, and constants by module, language constructs, extensions, and known limitations.

BCMath

Arbitrary-precision decimal arithmetic: the 14 PHP bcmath functions.

iconv

Character-set conversion and character-oriented string functions: the 10 PHP iconv functions.

PCNTL

Forking, waiting, process replacement, signals, sessions, daemonization, affinity, namespaces, and target-specific controls.

XML

The ext/xml SAX parser (XMLParser, xml_* functions, XML_* constants) and ext/xmlwriter (XMLWriter, xmlwriter_* functions).

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.

Network builtins

Builtins in the Network 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.

Database builtins

Builtins in the Database category.

Web builtins

Builtins in the Web category.

Image builtins

Builtins in the Image category.

XML builtins

Builtins in the XML 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.