← All docs

PHP Compatibility

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

Baseline: PHP 8.5.10 (CLI snapshot of 2026-09-04, 68 extensions, 2169 functions, 329 classes, 3180 constants).

Overall coverage: functions 883 / 2169 (41%), classes 142 / 329 (43%), constants 1094 / 3180 (34%).

Coverage by PHP module

Each cell counts the PHP-visible symbols a compiled elephc program has, against the symbols the module exposes in the baseline build. Any compile-time route counts once (registry builtin, injected prelude, name-resolver rewrite); symbols that exist only inside eval() are listed separately below. marks a kind the module does not have.

PHP moduleFunctionsClassesConstants
bcmath14 / 14 · 100%0 / 1 · 0%
bz20 / 10 · 0%
calendar18 / 18 · 100%21 / 21 · 100%
core29 / 62 · 47%21 / 40 · 52%34 / 89 · 38%
ctype4 / 11 · 36%
curl34 / 35 · 97%6 / 6 · 100%689 / 689 · 100%
date48 / 48 · 100%15 / 15 · 100%3 / 17 · 18%
dba0 / 15 · 0%0 / 1 · 0%
dom0 / 2 · 0%0 / 50 · 0%0 / 61 · 0%
enchant0 / 25 · 0%0 / 2 · 0%0 / 3 · 0%
exif4 / 4 · 100%1 / 1 · 100%
ffi0 / 5 · 0%
fileinfo0 / 6 · 0%0 / 1 · 0%0 / 11 · 0%
filter0 / 7 · 0%0 / 2 · 0%0 / 56 · 0%
ftp0 / 36 · 0%0 / 1 · 0%0 / 11 · 0%
gd83 / 106 · 78%1 / 2 · 50%67 / 89 · 75%
gettext0 / 10 · 0%
gmp0 / 51 · 0%0 / 1 · 0%0 / 9 · 0%
hash9 / 20 · 45%1 / 1 · 100%0 / 40 · 0%
iconv10 / 10 · 100%4 / 4 · 100%
intl0 / 187 · 0%0 / 22 · 0%0 / 170 · 0%
json5 / 5 · 100%2 / 2 · 100%27 / 29 · 93%
ldap0 / 55 · 0%0 / 3 · 0%0 / 92 · 0%
libxml0 / 8 · 0%0 / 1 · 0%0 / 28 · 0%
mbstring2 / 65 · 3%0 / 9 · 0%
mysqli84 / 106 · 79%4 / 6 · 67%52 / 110 · 47%
odbc0 / 48 · 0%0 / 2 · 0%0 / 57 · 0%
openssl4 / 64 · 6%0 / 3 · 0%3 / 70 · 4%
pcntl28 / 28 · 100%1 / 1 · 100%0 / 129 · 0%
pcre5 / 11 · 45%7 / 19 · 37%
pdo1 / 1 · 100%4 / 4 · 100%
pdo_dblib1 / 1 · 100%
pdo_firebird1 / 1 · 100%
pdo_mysql1 / 1 · 100%
pdo_odbc1 / 1 · 100%0 / 1 · 0%
pdo_pgsql1 / 1 · 100%
pdo_sqlite1 / 1 · 100%
pgsql0 / 123 · 0%0 / 3 · 0%0 / 76 · 0%
phar3 / 4 · 75%
posix2 / 41 · 5%0 / 43 · 0%
random3 / 9 · 33%0 / 11 · 0%0 / 2 · 0%
readline1 / 13 · 8%0 / 1 · 0%
reflection16 / 26 · 62%
session23 / 23 · 100%4 / 4 · 100%3 / 3 · 100%
shmop0 / 6 · 0%0 / 1 · 0%
simplexml0 / 3 · 0%0 / 2 · 0%
snmp0 / 24 · 0%0 / 2 · 0%0 / 21 · 0%
soap0 / 2 · 0%0 / 8 · 0%0 / 81 · 0%
sockets0 / 37 · 0%0 / 2 · 0%0 / 243 · 0%
sodium0 / 104 · 0%0 / 1 · 0%0 / 94 · 0%
spl15 / 15 · 100%54 / 55 · 98%
sqlite30 / 4 · 0%0 / 12 · 0%
standard381 / 545 · 70%2 / 6 · 33%155 / 400 · 39%
sysvmsg0 / 7 · 0%0 / 1 · 0%0 / 5 · 0%
sysvsem0 / 4 · 0%0 / 1 · 0%
sysvshm0 / 7 · 0%0 / 1 · 0%
tidy0 / 24 · 0%0 / 2 · 0%0 / 161 · 0%
tokenizer0 / 2 · 0%0 / 1 · 0%0 / 154 · 0%
uri0 / 9 · 0%
xml22 / 22 · 100%1 / 1 · 100%28 / 28 · 100%
xmlreader0 / 1 · 0%
xmlwriter42 / 42 · 100%1 / 1 · 100%
xsl0 / 1 · 0%0 / 14 · 0%
zend opcache8 / 8 · 100%
zip0 / 10 · 0%0 / 1 · 0%
zlib4 / 30 · 13%0 / 2 · 0%0 / 27 · 0%

The counts above are what a compiled program has. Code run through eval() sees a different set in these modules (compiled / eval()):

  • core functions: 29 / 28
  • core constants: 34 / 31
  • exif functions: 4 / 0
  • exif constants: 1 / 0
  • gd functions: 83 / 0
  • gd constants: 67 / 0
  • mysqli functions: 84 / 0
  • mysqli constants: 52 / 0
  • pdo functions: 1 / 0
  • session functions: 23 / 0
  • standard functions: 381 / 341
  • standard constants: 155 / 134
  • zend opcache functions: 8 / 0

3 symbol(s) exist only inside eval() and are not counted in the table: get_called_class(), get_class_methods(), get_class_vars().

The remaining 2 baseline extensions expose no functions, classes, or constants of their own, so they have no row above: lexbor, mysqlnd.

In addition, elephc implements 5 PHP language constructs that PHP does not count as functions: die(), empty(), exit(), isset(), unset().

elephc also defines 1 constant(s) at runtime that PHP registers only in specific states and never lists statically: SID.

elephc also implements 1 symbol(s) that PHP added AFTER this baseline release, so they cannot be counted against it: SortDirection (PHP 8.6).

The baseline PHP build does not expose these platform-dependent symbols, so they are excluded from its coverage percentages: pcntl_getcpu() (PHP build guard HAVE_SCHED_GETCPU), pcntl_getqos_class() (target-specific), pcntl_setns() (PHP build guard HAVE_PIDFD_OPEN), pcntl_setqos_class() (target-specific).

elephc also provides 91 symbols from PECL extensions php-src does not bundle, which the baseline cannot measure: cairo (48 functions, 26 classes), gmagick (6 classes), imagick (10 classes), pdo_ibm (1 classes).

Language constructs

FeatureStatusNotes
Classes & objects (PHP)✅ Supported
Inheritance, interfaces, abstract classes (PHP)✅ Supported
Traits (PHP)✅ Supported
Enums (PHP)✅ Supported
Anonymous classes (PHP)✅ Supported
Constructor property promotion (PHP)✅ Supported
Property hooks (PHP)✅ Supported
Attributes (PHP)✅ Supported
Magic methods (PHP)✅ SupportedSee the classes page for the supported set
Static properties, methods, late static binding (PHP)✅ Supported
Union & intersection types (PHP)✅ Supported
Closures & arrow functions (PHP)✅ Supported
First-class callable syntax (PHP)✅ Supported
Generators (PHP)✅ SupportedLowered onto stackful coroutines
Fibers (PHP)✅ Supported
Exceptions (try / catch / finally) (PHP)✅ Supported
match expressions (PHP)✅ Supported
References (&) (PHP)✅ Supported
Namespaces (PHP)✅ Supported
include / require (PHP)✅ SupportedStatic, compile-time resolved paths
eval() (PHP)🟡 PartialExperimental; embeds an optional interpreter bridge when runtime parsing is required

Extensions

FeatureStatusNotes
PDO (PHP)✅ SupportedDriver matrix documented on the PDO page
mysqli (PHP)🟡 PartialLocked v1 subset over the elephc-pdo bridge; divergences on the mysqli page
Sessions (PHP)✅ SupportedIn —web binaries
Streams (PHP)🟡 Partial
SPL (PHP)🟡 Partial
Reflection (PHP)🟡 Partial
DateTime (PHP)🟡 Partial
Calendar (PHP)✅ Supported
iconv (PHP)✅ Supported
GD / image (PHP)🟡 PartialEnabled with —with-image
PCNTL (PHP)✅ SupportedTarget-aware Unix process control; auto-linked or forced with —with-pcntl
XML (PHP)✅ Supportedext/xml SAX parser (22 functions, XMLParser, 28 constants) and ext/xmlwriter (42 functions, XMLWriter) on a pinned static libxml2 2.15.3 from the native catalog (elephc native add libxml2); auto-linked or forced with —with-xml, identical inside eval(); the surface is complete, with the runtime’s per-handler-invocation heap cost documented under Runtime limits in docs/php/xml.md
cURL (PHP)✅ SupportedAll 35 functions, 6 classes and 689 constants on a pinned static libcurl 8.21.0; declare the managed curl package (elephc native add curl). 260 of 271 CURLOPT_* implemented, the rest rejected with PHP’s warning. eval() covers the easy, multi and share interfaces. The coverage row counts the 34 shared-contract functions; curl_file_create() is a plain prelude alias of the CURLFile constructor with no registry binding on either backend, so it carries no shared contract and is the one function the row does not count.
OpenSSL (PHP)🟡 PartialEncrypt/decrypt subset
OPcache (PHP)🟡 PartialCompatibility surface; programs are AOT-compiled, there is no opcode cache

Beyond PHP

elephc-specific builtins with no PHP equivalent (not counted in coverage above):

BuiltinAreaDescription
buffer_free()BufferFrees a buffer and nulls the local variable that held it.
buffer_len()BufferReturns the logical element count of a buffer.
class_attribute_args()ClassReturns the constructor arguments of a named attribute applied to a class.
class_attribute_names()ClassReturns the list of attribute names applied to a class.
class_get_attributes()ClassReturns an array of ReflectionAttribute objects for all attributes of a class.
read_exif_data()ImageImplemented by the compiler-injected image prelude.
clamp()MathClamps a value to be within a specified range. (No PHP equivalent (not in PHP 8.4/8.5))
log2()MathReturns the base-2 logarithm of a number. (No PHP equivalent (PHP has log(), log10(), log1p()))
pcntl_daemon()MiscDetaches the surviving child into a background daemon process.
buffer_new()PointerAllocates a raw byte buffer.
ptr()PointerReturns a raw pointer to the given variable.
ptr_get()PointerReads one machine word through a raw pointer and returns it as an integer.
ptr_is_null()PointerReturns true if the pointer is null.
ptr_null()PointerReturns a null raw pointer.
ptr_offset()PointerReturns a new pointer offset from the given pointer by the given byte count.
ptr_read16()PointerReads one unsigned 16-bit word through a raw pointer and returns it as an integer.
ptr_read32()PointerReads one unsigned 32-bit word through a raw pointer and returns it as an integer.
ptr_read8()PointerReads one unsigned byte through a raw pointer and returns it as an integer.
ptr_read_string()PointerCopies raw bytes from a pointer into a PHP string of the given length.
ptr_set()PointerWrites one machine word through a raw pointer.
ptr_sizeof()PointerReturns the byte size of the named pointer target type.
ptr_write16()PointerWrites one 16-bit word through a raw pointer.
ptr_write32()PointerWrites one 32-bit word through a raw pointer.
ptr_write8()PointerWrites one byte through a raw pointer.
ptr_write_string()PointerCopies PHP string bytes into raw memory at the given pointer.
zval_free()PointerFrees a PHP zval pointer allocated by zval_pack.
zval_pack()PointerPacks an elephc runtime value into a heap-allocated PHP zval pointer.
zval_type()PointerReturns the PHP zval type byte for a zval pointer.
zval_unpack()PointerUnpacks a PHP zval pointer into an owned elephc Mixed value.
grapheme_strrev()StringReverses a string by grapheme cluster, returning false on failure. (No PHP equivalent (not in PHP 8.4/8.5 intl))
is_real()TypeAlias of is_float(). (Removed in PHP 8.0; kept as a compatibility alias of is_float())

Classes: DateUnknownException (date), ImageException (gd).

Constants: ARRAY_FILTER_USE_VALUE (standard), MYSQLI_TYPE_VARCHAR (mysqli).

Known limitations

Static subset, AOT only. Ordinary source is compiled ahead of time with no opcode fallback; runtime code loading exists only through the experimental eval() interpreter bridge.

Coverage measured against a pinned baseline. Builtin percentages are computed against the vendored PHP CLI snapshot (version and extension set recorded in the page header). PHP modules outside that snapshot are not counted.

Five native compile targets. Standalone binaries target macOS ARM64, Linux ARM64, and Linux x86_64; macOS also cross-compiles libraries for iOS ARM64 devices and the iOS ARM64 Simulator. PHP itself runs on many more platforms.

A Mixed-sourced object needs explicit narrowing before a typed object parameter. An object pulled out of an array, an array property, or other mixed-typed storage is rejected at a class-typed call parameter until an instanceof guard narrows it; PHP would defer that check to runtime. Once narrowed, elephc unboxes the object and passes it correctly. The curl multi wrappers accept mixed plus a runtime guard because curl_multi_info_read() returns its handle inside an array and canonical callers do not add a separate narrowing guard. Pinned by test_mixed_sourced_object_through_typed_param_is_unboxed.