elephc elephc
HomeHow it worksFeaturesResourcesDocs
Home How it works Features Resources Docs

Getting Started

  • Installation
  • Your First Program

How-To

  • Build a Fiber Web Server

Compiling

  • Compiling Overview
  • The compilation pipeline
  • CLI reference
  • Targets and cross-compilation
  • Optimization and codegen controls
  • Output formats and diagnostics
  • Source maps
  • Linking, heap, and conditional compilation
  • Native dependencies

PHP Syntax

  • Types
  • Operators
  • Control Structures
  • Functions
  • Eval
  • Strings
  • Regex
  • Arrays
  • Math
  • Classes
  • SPL
  • Namespaces
  • Sessions
  • System & I/O
  • Streams
  • Magic Constants
  • Fibers
  • Generators
  • cURL
  • Date and Time
  • Images
  • mysqli (MySQL / MariaDB)
  • PDO (Databases)
  • Calendar
  • OPcache
  • PHP Compatibility
  • BCMath
  • iconv
  • PCNTL
  • XML
  • Builtins

    • Builtins
    • Array builtins
    • Buffer builtins
    • Class builtins
    • Database builtins
    • Date builtins
    • Filesystem builtins
    • Image builtins
    • IO builtins
    • JSON builtins
    • Math builtins
      • abs()
      • acos()
      • asin()
      • atan()
      • atan2()
      • base_convert()
      • bcadd()
      • bcceil()
      • bccomp()
      • bcdiv()
      • bcdivmod()
      • bcfloor()
      • bcmod()
      • bcmul()
      • bcpow()
      • bcpowmod()
      • bcround()
      • bcscale()
      • bcsqrt()
      • bcsub()
      • bindec()
      • ceil()
      • clamp()
      • cos()
      • cosh()
      • decbin()
      • dechex()
      • decoct()
      • deg2rad()
      • exp()
      • fdiv()
      • floor()
      • fmod()
      • hexdec()
      • hypot()
      • intdiv()
      • is_finite()
      • is_infinite()
      • is_nan()
      • log()
      • log10()
      • log2()
      • max()
      • min()
      • mt_rand()
      • octdec()
      • pi()
      • pow()
      • rad2deg()
      • rand()
      • random_int()
      • round()
      • sin()
      • sinh()
      • sqrt()
      • tan()
      • tanh()
    • Misc builtins
    • Network builtins
    • Pointer builtins
    • Process builtins
    • Regex builtins
    • SPL builtins
    • Streams builtins
    • String builtins
    • Type builtins
    • Web builtins
    • XML builtins

Beyond PHP

  • LFC Source Files
  • Pointers
  • Buffers
  • Packed Classes
  • FFI & Extern
  • Conditional Compilation
  • Shared Libraries (cdylib)
  • Web Server (--web)
  • zval Bridge
  • Profiling (elephc monitor)

Compiler Internals

  • What is a Compiler?
  • The Pipeline
  • The Lexer
  • The Parser
  • The Type Checker
  • The Optimizer
  • The Code Generator
  • The Runtime
  • Eval Runtime Architecture
  • Memory Model
  • Architecture
  • ARM64 Assembly
  • ARM64 Instructions
  • The EIR Design
  • Builtins

    • _internal builtins
    • array builtins
    • buffer builtins
    • class builtins
    • database builtins
    • date builtins
    • filesystem builtins
    • image builtins
    • io builtins
    • json builtins
    • math builtins
    • misc builtins
    • network builtins
    • pointer builtins
    • process builtins
    • regex builtins
    • spl builtins
    • streams builtins
    • string builtins
    • type builtins
    • web builtins
    • xml builtins
← All docs

abs()

Absolute value.

abs()

function abs(int $num): mixed

Absolute value.

Parameters:

  • $num (int)

Returns: mixed

Availability

  • Compiled (AOT): supported by the Elephc code generator.
  • eval() (magician interpreter): supported — declarative interpreter builtin (crates/elephc-magician/src/interpreter/builtins/math/abs.rs).

No examples yet — check examples/ and showcases/ for usage patterns.

Internals

For how abs is implemented in the compiler, see the internals page.

Next

acos()

elephc

An open-source PHP compiler that lowers a static subset of PHP to native assembly for macOS ARM64, Linux ARM64, Linux x86_64, and iOS ARM64 library targets. Written in Rust. MIT licensed.

Project

GitHub Installation Examples Documentation

Learn

How it works Language reference Resources ARM64 assembly primer Memory model

The story

My first "serious programming" book was PHP 4 and MySQL. That book turned passion into profession. elephc fills a gap I always missed — compiling PHP modules to native code without leaving the PHP ecosystem behind.

// coming next

Want to be among the first to explore cloud-native compiled PHP? Create artifacts, ship native binaries, and host projects built with elephc - no traditional runtime required.

Sign up for elephc.cloud →

Made with ❤️ in Canzano by Vincenzo Petrucci [at] Illegal Studio

MIT License © 2026 Vincenzo Petrucci