Everything your PHP does.
Now in JavaScript.

Pext doesn't cut corners. Here's a precise audit of every PHP feature and pattern we support, and what's still on the roadmap.

01
01

Language Constructs

Core PHP syntax faithfully reproduced, from variables and types to closures, generators, and attributes.

10 supported 5 partial 1 not supported
  • Inline HTML mixed with PHP is not supported; files are treated as pure PHP code
  • The transpiler assumes each file is a self-contained PHP script
  • Comments (//, #, /* */, /** */) are parsed but not carried over to JS output
  • Type declarations are dropped at transpile time (types on parameters, properties, and return values are not carried over to JS; some information is preserved in reflection data)
  • null is fully supported
  • Booleans are fully supported
  • int and float are fully supported as distinct PHP types; the runtime preserves the type tag so is_int, is_float, gettype, and coercion rules behave identically to PHP
  • Strings are fully supported
  • Arrays and objects are fully supported
  • Resources and callables are fully supported
  • self, static, parent type references are fully supported
  • Iterables are fully supported PHP 7.1
  • Type juggling (loose comparisons and coercions) is fully supported
  • Standard variable declaration and assignment
  • Pass-by-reference (&$var) fully supported
  • Variable variables ($$name) supported
  • global and static variable keywords
  • Proper scope isolation between functions and global scope
  • isset(), unset(), empty(), define() language constructs fully supported
  • define() and const declarations
  • Class constants and interface constants
  • Magic constants: __FILE__, __LINE__, __CLASS__, __FUNCTION__, __METHOD__, __NAMESPACE__, __DIR__
  • Arithmetic: +, -, *, /, %, ** (exponentiation)
  • Comparison: ==, ===, !=, !==, <, >, <=, >=, <=> (spaceship)
  • Logical: &&, ||, !, and, or, xor
  • Bitwise: &, |, ^, ~, <<, >>
  • String concatenation (.) and concatenation assignment (.=)
  • Increment/decrement: ++$a, $a++, --$a, $a--
  • Assignment: by reference (=&), arithmetic (+=, -=, *=, /=, %=, **=), bitwise (&=, |=, ^=, <<=, >>=), string (.=), and nested assignments
  • Null coalescing: ?? introduced in 7.0, ??= in 7.4; spread (...) introduced in 5.6 PHP 7.0
  • Not supported: execution operator (backtick), pipe operator (|>) In Progress
  • if / elseif / else and ternary (?:)
  • switch and match expressions (with strict comparison) PHP 8.0
  • for, foreach (with key-value unpacking), while, do-while
  • break and continue, including level argument (break 2)
  • return with and without values
  • File inclusion: include, include_once, require, require_once
  • Not supported: goto, declare
  • Named functions and methods
  • Closures with use() bindings (by value and by reference)
  • Arrow functions (fn() =>) and anonymous functions (function() {}) PHP 7.4
  • Variadic arguments (...$args)
  • Named arguments are preprocessed at transpile time into positional arguments; dynamic function invocation with named arguments is not supported PHP 8.0
  • Default parameter values and nullable parameters
  • First-class callable syntax PHP 8.1
  • Properties and class constants are supported
  • Property and method visibility (public, protected, private) is not enforced at runtime
  • Property hooks are not yet supported In Progress PHP 8.4
  • Autoloading is fully supported
  • Inheritance is fully supported
  • Scope resolution (::) is fully supported
  • Interfaces are partially supported: present in reflection data but their types are not enforced
  • Traits are fully supported
  • Anonymous classes are minimally supported PHP 7.0
  • Overloading is supported
  • Object iteration is supported
  • Magic methods: __get, __set, __construct, __destruct, __isset, __unset, __invoke, __toString are supported; others are partially supported
  • Object destructors (__destruct) fire deterministically on scope exit: the runtime tracks reference counts and invokes __destruct when an object reaches zero references, matching PHP's lifecycle semantics New
  • final keyword is dropped at transpile time
  • Late static binding is supported
  • Object references are fully supported, including referencing object properties by reference New
  • Cloning and comparing are minimally supported In Progress
  • Object serialization is minimally supported
  • Lazy objects are not supported PHP 8.4
  • Predefined interfaces and classes (Countable, Iterator, ArrayAccess, Stringable, etc.) are supported PHP 8.0
  • Namespaces are fully supported at runtime
  • Sub-namespaces with arbitrary depth are fully supported
  • Integration with dynamic features (dynamic class instantiation, function calls, etc.) is supported
  • Aliasing via use ... as ... is supported
  • Fallback to global scope for unqualified names is supported
  • try / catch (multi-catch with |) / finally PHP 8.0
  • Custom exception class hierarchies
  • set_error_handler and set_exception_handler
  • trigger_error and PHP error level constants
  • Throwable interface and Error base class PHP 7.0
  • Predefined exceptions (RuntimeException, InvalidArgumentException, LogicException, etc.) are supported
  • Passing by reference (&$var in function signatures) is supported
  • Copy on write semantics are supported
  • Returning references from functions is not yet supported In Progress
  • Unsetting references (unset($ref)) is not yet supported In Progress
  • yield by value and by reference
  • yield from and generator delegation PHP 7.0
  • Generator::send() and Generator::throw() In Progress
  • Return values from generators (Generator::getReturn()) In Progress PHP 7.0
  • #[Attribute] declaration syntax PHP 8.0
  • Attribute targeting: class, method, property, parameter, function, constant PHP 8.0
  • Runtime access via ReflectionAttribute PHP 8.0
  • Repeatable attributes PHP 8.0
  • Predefined attributes: #[SensitiveParameter] (8.2), #[Override] and #[Deprecated] (8.3) PHP 8.2
  • Trait composition (use Trait)
  • Abstract trait methods
  • Trait constants PHP 8.2
  • Basic (unit) enums PHP 8.1
  • Backed enums (string and int) PHP 8.1
  • Enum methods and constants PHP 8.1
  • Runtime constants: PHP_INT_MAX, PHP_INT_MIN, PHP_FLOAT_MAX, PHP_EOL, PHP_MAJOR_VERSION, PHP_VERSION, and more
  • true, false, null literals
  • Web server superglobals not available: $_SERVER, $_GET, $_POST, $_FILES, $_SESSION, $_COOKIE In Progress
  • Pext does not currently embed a web server runtime
  • PHP 8.1 Fibers are not currently supported
  • Lightweight concurrency primitives are not yet part of the Pext runtime
02
02

Standard Library

PHP's bundled standard extension: the always-available API for arrays, strings, math, file I/O, and the rest of core PHP, reimplemented natively in the Pext runtime.

12 supported 4 partial
  • array_map, array_filter, array_reduce, array_walk
  • array_merge, array_slice, array_splice, array_chunk, array_combine
  • Sorting: sort, rsort, usort, ksort, uasort, array_multisort
  • array_key_exists, in_array, array_search, array_unique, array_flip
  • array_push, array_pop, array_shift, array_unshift
  • compact and extract
  • Directory class with read, rewind, close instance methods
  • dir() factory returning a Directory handle
  • chdir() for changing the working directory
  • Pairs with the File System module for full PHP filesystem coverage
  • error_reporting, set_error_handler, restore_error_handler
  • set_exception_handler, restore_exception_handler
  • trigger_error, user_error
  • error_get_last, error_clear_last
  • file_get_contents, file_put_contents, file_exists, file
  • mkdir, rmdir, rename, copy, unlink, symlink
  • opendir, readdir, closedir, scandir, glob
  • is_file, is_dir, is_readable, is_writable, filesize, filemtime
  • realpath, dirname, basename, pathinfo
  • PHP_VERSION, PHP_MAJOR_VERSION, PHP_OS, PHP_INT_MAX, PHP_EOL, and similar constants
  • phpversion(), php_uname(), ini_get(), ini_set() supported
  • phpinfo() and web-server-related info functions not available
  • Arithmetic: abs, max, min, pow, sqrt, hypot, intdiv, fmod, fdiv
  • Rounding: ceil, floor, round
  • Trigonometric: sin, cos, tan, asin, acos, atan, atan2, deg2rad, rad2deg, pi
  • Hyperbolic: sinh, cosh, tanh, asinh, acosh, atanh
  • Exponential and logarithmic: exp, expm1, log, log10, log1p
  • Base conversion: bindec, decbin, hexdec, dechex, octdec, decoct, base_convert
  • Floating-point predicates: is_finite, is_infinite, is_nan
  • RoundingMode enum: HalfAwayFromZero, HalfTowardsZero, HalfEven, HalfOdd, TowardsZero, AwayFromZero, NegativeInfinity, PositiveInfinity PHP 8.4
  • Math constants: M_E, M_PI, M_PI_2, M_PI_4, M_1_PI, M_2_PI, M_SQRTPI, M_2_SQRTPI, M_SQRT2, M_SQRT3, M_SQRT1_2, M_LOG2E, M_LOG10E, M_LN2, M_LN10, M_LNPI, M_EULER, INF, NAN
  • Rounding constants: PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, PHP_ROUND_HALF_ODD
Read the audit deep-dive
  • pack and unpack covering the full PHP format-character set, including endian markers and repeat counts
  • sleep, usleep, time_nanosleep, time_sleep_until
  • register_shutdown_function, register_tick_function, unregister_tick_function
  • uniqid, getmypid, getmygid, getmyuid
  • highlight_string, highlight_file for source-colorized output
  • connection_aborted, connection_status, ignore_user_abort wired into the SAPI shim
  • dns_get_record with A, AAAA, MX, TXT, NS, SOA, PTR, CNAME, CAA, SRV
  • Synchronous resolution backed by a worker so user code keeps the PHP blocking semantics
  • header, headers_sent, http_response_code for SAPI response control
  • ob_start, ob_end_clean, ob_end_flush, ob_get_contents, ob_get_clean
  • ob_flush, ob_get_level, ob_get_length
  • echo, print, print_r, var_dump, var_export
  • Output buffering tied to non-web runtime; some behaviors differ from PHP's web SAPI In Progress
  • password_hash with PASSWORD_BCRYPT, PASSWORD_ARGON2I, PASSWORD_ARGON2ID
  • password_verify with constant-time comparison
  • password_needs_rehash for cost and algorithm migration
  • password_get_info for hash inspection
  • Default algorithm and cost track PHP, so hashes round-trip between PHP and Pext without rehashing
  • password_algos for the active algorithm list
  • proc_open, proc_close, proc_get_status, proc_terminate
  • passthru, exec, shell_exec, system
  • popen, pclose
  • pipes and stream handling for stdin/stdout/stderr In Progress
  • mt_rand and rand using Mersenne Twister, seedable for reproducible runs
  • random_int and random_bytes backed by a cryptographically secure source
  • mt_getrandmax, mt_srand, srand
  • stream_context_create plus the full get_options, set_option, params family
  • stream_get_contents, stream_get_line, stream_get_meta_data, stream_copy_to_stream
  • stream_socket_client, stream_socket_server, stream_socket_accept, stream_socket_sendto, stream_socket_recvfrom
  • stream_socket_enable_crypto for TLS upgrades
  • stream_filter_register, stream_filter_append, stream_filter_prepend, stream_filter_remove
  • stream_wrapper_register, stream_wrapper_unregister, stream_wrapper_restore
  • stream_select, stream_set_blocking, stream_set_timeout, stream_set_chunk_size
  • Some advanced wrapper protocols are still in progress In Progress
  • str_replace, str_contains, str_starts_with, str_ends_with, substr, strpos, strlen
  • explode, implode, trim, ltrim, rtrim, str_pad, str_repeat, str_split
  • strtolower, strtoupper, ucfirst, ucwords, lcfirst
  • sprintf, printf, number_format, money_format
  • Multibyte string functions (mb_*)
  • str_contains, str_starts_with, str_ends_with PHP 8.0
  • parse_url with the full PHP_URL_* component set
  • urlencode, urldecode, rawurlencode, rawurldecode
  • http_build_query with nested arrays and configurable separators
  • base64_encode, base64_decode
  • isset, empty, unset, is_null, is_bool, is_int, is_float, is_string, is_array, is_object
  • gettype, settype, get_debug_type PHP 8.0
  • intval, floatval, strval, boolval
  • var_dump, var_export, print_r, serialize, unserialize
  • is_numeric, is_callable, is_iterable, is_countable
03
03

Extensions

PHP's extension layer: BCMath, Date, Intl, MySQLi, GD, OpenSSL, SQLite3, and the rest of the modules you enable in php.ini. Implemented as standalone Pext runtime packages.

19 supported 4 partial 2 not supported
  • Arbitrary precision arithmetic fully supported with PHP-identical scale handling
  • bcadd, bcsub, bcmul, bcdiv, bcmod, bcdivmod
  • bcpow, bcpowmod, bcsqrt
  • bccomp for arbitrary-precision comparison
  • bcscale for reading and setting the global default scale
  • bcceil, bcfloor, bcround PHP 8.4
  • ctype_alpha, ctype_alnum, ctype_digit, ctype_xdigit
  • ctype_lower, ctype_upper, ctype_space
  • ctype_punct, ctype_print, ctype_graph, ctype_cntrl
  • Byte-classification semantics matching PHP
  • curl_init, curl_setopt, curl_setopt_array, curl_exec, curl_reset, curl_close
  • Full CURLOPT_* surface: URL, custom HTTP methods, headers, request body, redirects, timeouts, TLS verification, cookies, proxy
  • curl_getinfo for response metadata, timing, and certificate info
  • curl_multi_init, curl_multi_add_handle, curl_multi_exec, curl_multi_select for parallel requests
  • curl_error, curl_errno, curl_strerror, curl_version
  • CURLFile uploads and CURLStringFile streaming uploads PHP 8.1
  • DateTime and DateTimeImmutable classes
  • DateInterval and DatePeriod
  • date, strtotime, mktime, time, microtime, checkdate
  • date_create, date_format, date_diff, date_add, date_sub
  • DOMDocument, DOMElement, DOMAttr, DOMText nodes supported
  • DOMXPath queries supported
  • createElement, appendChild, getElementById, getElementsByTagName
  • loadHTML, loadXML, saveHTML, saveXML
  • Some advanced DOM manipulation methods are in progress In Progress
  • FileHandlingError
  • FileInfo
  • FileObject
  • filter_var and filter_var_array for one-shot validation and sanitization
  • filter_input and filter_input_array for GET, POST, COOKIE, SERVER, ENV
  • filter_has_var, filter_id, filter_list
  • Validate filters: FILTER_VALIDATE_INT, FLOAT, BOOL, EMAIL, URL, IP, REGEXP, DOMAIN, MAC
  • Sanitize filters: FILTER_SANITIZE_STRING, EMAIL, URL, NUMBER_INT, NUMBER_FLOAT, SPECIAL_CHARS
  • Full option and flag set, including FILTER_NULL_ON_FAILURE and FILTER_FORCE_ARRAY
  • imagecreate, imagecreatetruecolor, imagedestroy, imagecopy, imagecopyresampled, imagecopyresized
  • PNG, JPEG, GIF, WebP, BMP, AVIF readers and writers (imagepng, imagejpeg, imagegif, imagewebp, imagebmp, imageavif)
  • imagettftext and imagettfbbox for TrueType font rendering
  • Drawing primitives: imagefilledrectangle, imageline, imageellipse, imagefilledpolygon, imagestring
  • imagecolorallocate, imagecolortransparent, imagecolorat, imagecolorsforindex
  • imagecreatefrompng, imagecreatefromjpeg, imagecreatefromgif, imagecreatefromwebp
  • The GMP extension is not currently supported
  • For arbitrary precision arithmetic, use BCMath or brick/math
  • hash, hash_file, hash_hmac, hash_hmac_file with the full PHP algorithm set
  • Incremental hashing via hash_init, hash_update, hash_update_file, hash_final, hash_copy
  • hash_pbkdf2 for password-based key derivation
  • hash_hkdf for HMAC-based key derivation
  • hash_algos and hash_hmac_algos listing the available digests (md5, sha1, sha2 family, sha3 family, blake2, ripemd, fnv, crc32, xxhash)
  • hash_equals for timing-safe comparison
  • Locale class for locale parsing, composition, and matching
  • Transliterator runs on the transliteration npm package rather than ICU, so transform IDs map to a best-effort romanization and do not match PHP's ICU output byte for byte; a custom ICU4x WASM build is on the enterprise roadmap In Progress
  • Normalizer for NFC, NFD, NFKC, NFKD
  • MessageFormatter for ICU MessageFormat
  • Spoofchecker for confusable detection
  • idn_to_ascii and idn_to_utf8 for internationalized domain names
Read the transliteration deep-dive
  • Iterator and IteratorAggregate interfaces
  • ArrayIterator, ArrayObject
  • SplStack, SplQueue, SplHeap, SplMinHeap, SplMaxHeap
  • SplDoublyLinkedList, SplFixedArray
  • RecursiveIterator and RecursiveIteratorIterator
  • json_encode with all flags (JSON_PRETTY_PRINT, JSON_UNESCAPED_UNICODE, JSON_THROW_ON_ERROR, etc.)
  • json_decode with associative array and object modes
  • json_last_error, json_last_error_msg
  • json_validate PHP 8.3
  • libxml_use_internal_errors, libxml_get_errors, libxml_clear_errors
  • LIBXML_* constants supported
  • Some advanced libxml options are in progress In Progress
  • Memcached class with addServer, addServers, getServerList, resetServerList
  • get, set, add, replace, delete, touch, increment, decrement
  • getMulti, setMulti, deleteMulti, getMultiByKey for bulk operations
  • CAS via getByKey, setByKey, cas, casByKey
  • Memcached::OPT_* options for compression, serialization, prefix keys, binary protocol, connect timeout
  • getStats, getVersion, getResultCode, getResultMessage
  • mb_strlen, mb_strpos, mb_substr operating on codepoints rather than bytes
  • mb_strtolower, mb_convert_case for Unicode case folding
  • mb_chr for codepoint to character conversion
  • mb_convert_encoding for encoding conversion across UTF-8, UTF-16, ISO-8859, and the common PHP aliases
  • mb_detect_encoding, mb_internal_encoding, mb_language
See it in action on email-validator
  • mysqli class with constructor, real_connect, close, ping, change_user, select_db
  • query, real_query, multi_query, prepare, store_result, use_result
  • mysqli_stmt with bind_param, execute, bind_result, fetch, get_result, affected_rows, insert_id
  • mysqli_result with fetch_assoc, fetch_array, fetch_object, fetch_all, fetch_field, num_rows, data_seek
  • Transaction control: autocommit, begin_transaction, commit, rollback, savepoint
  • Connection options including charset, SSL/TLS, connect timeout, init command
  • openssl_encrypt and openssl_decrypt across AES-CBC, AES-GCM, AES-CTR, ChaCha20-Poly1305
  • openssl_digest and openssl_random_pseudo_bytes
  • openssl_pkey_new, openssl_pkey_get_private, openssl_pkey_get_public, openssl_pkey_export, openssl_pkey_get_details
  • openssl_sign, openssl_verify, openssl_seal, openssl_open
  • openssl_x509_parse, openssl_x509_read, openssl_x509_checkpurpose, openssl_x509_verify
  • openssl_csr_new, openssl_csr_sign, openssl_csr_get_subject, openssl_csr_get_public_key
  • openssl_cipher_iv_length, openssl_cipher_key_length, openssl_get_cipher_methods, openssl_get_md_methods
  • preg_match, preg_match_all, preg_replace, preg_replace_callback, preg_split
  • Named capture groups, backreferences, lookahead/lookbehind
  • PREG_OFFSET_CAPTURE, PREG_SET_ORDER, PREG_PATTERN_ORDER flags
  • preg_quote, preg_last_error
  • ReflectionClass: name, methods, properties, constants, interfaces, traits
  • ReflectionMethod, ReflectionProperty, ReflectionParameter
  • ReflectionFunction, ReflectionExtension
  • ReflectionAttribute for reading #[Attributes] at runtime PHP 8.0
  • Some advanced reflection capabilities (closures, generators) are in progress In Progress
  • session_start, session_destroy, session_commit, session_abort, session_reset
  • session_id, session_name, session_status, session_regenerate_id, session_create_id
  • session_encode, session_decode for PHP-compatible serialization
  • session_set_save_handler and SessionHandlerInterface for custom backends
  • session_get_cookie_params, session_set_cookie_params, session_cache_limiter, session_cache_expire
  • session_gc, session_save_path, session_module_name, session_register_shutdown, session_unset, session_write_close
  • SimpleXMLElement and SimpleXMLIterator with PHP-style property and child access
  • simplexml_load_string, simplexml_load_file, simplexml_import_dom
  • xpath() queries and attribute access via attributes()
  • asXML for serialization back to XML
  • SQLite3 class with open, close, exec, query, prepare, querySingle
  • SQLite3Stmt with bindParam, bindValue, execute, reset, clear, paramCount
  • SQLite3Result with fetchArray (SQLITE3_ASSOC, SQLITE3_NUM, SQLITE3_BOTH), finalize, numColumns, columnName, columnType
  • Transactions via BEGIN, COMMIT, ROLLBACK, plus savepoints
  • createFunction and createAggregate for user-defined SQL functions written in PHP
  • lastInsertRowID, changes, lastErrorCode, lastErrorMsg, busyTimeout
  • token_get_all is not currently supported at runtime
  • PhpToken is not currently supported at runtime
  • The transpiler does its own lexing at build time, so runtime tokenization has been left for the few libraries that introspect PHP source from inside the running program
  • ZipArchive class for reading and writing zip archives
  • open, close, addFile, addFromString, addEmptyDir
  • extractTo, getFromName, getFromIndex, getNameIndex, statIndex
  • deleteName, deleteIndex, renameName, renameIndex
  • Full ZipArchive constant set (CREATE, OVERWRITE, EXCL, CHECKCONS, ER_*)

Ready to break free from PHP?

Book a personalized demo and see how Pext can transform your codebase from legacy PHP to modern JavaScript, without rewriting a single line by hand.