.TH PHP 1 "2026-09-27" "phplang 0.2.13" "User Commands"
.SH NAME
php \- compiled PHP runtime on the fusevm bytecode VM
.SH SYNOPSIS
.B php
[\fIOPTIONS\fR]
[\fIFILE\fR]
[\fIARGV\fR...]
.br
.B php
\-r \fICODE\fR
.br
.B php
\-a
.SH DESCRIPTION
.B phplang
runs PHP programs by lexing and parsing to an AST, lowering to
.B fusevm
bytecode, and executing on the fusevm bytecode VM with a tracing Cranelift
JIT for hot arithmetic loops. There is no bespoke PHP VM or JIT; execution
and codegen live entirely in fusevm. PHP object semantics (arrays, strings,
type coercion) are served by a runtime host on top of the VM.
.PP
Source files use the standard \(oq\fI<?php ... ?>\fR\(cq and
\(oq\fI<?= ... ?>\fR\(cq tags; any text outside a PHP tag is passed through
verbatim as inline HTML.
.SH OPTIONS
.TP
.BR \-r ", " \-\-run " " \fICODE\fR
Run PHP code given directly on the command line, e.g.
\(oq\fIphp \-r 'echo 1+1;'\fR\(cq. The code is run as if wrapped in
\fI<?php ... ?>\fR; no opening tag is required.
.TP
.BR \-a ", " \-\-interactive
Start the interactive REPL. Also entered automatically when
.B php
is run with no
.I FILE
and stdin is a TTY.
.TP
.BR \-d ", " \-\-define " " \fINAME\fR[=\fIVALUE\fR]
Set an ini entry before the source is read, e.g.
\(oq\fIphp \-d error_reporting=0\fR\(cq. Repeatable; a later
.B \-d
for the same name wins, and
.B \-d
.I NAME
with no
.I =VALUE
sets it to \fI1\fR.
.I error_reporting
takes the php.ini spelling, so
\(oq\fI\-d 'error_reporting=E_ALL & ~E_DEPRECATED'\fR\(cq works. Because this
applies before the source is read, it is the only way to suppress a
COMPILE-time notice such as \fIUsing ${var} in strings is deprecated\fR; the
run-time
.BR error_reporting ()
function cannot, since the notice was already raised.
.TP
.B \-\-tiers
Run it, then report which fusevm execution tier took each of its chunks.
.TP
.B \-\-dump\-bytecode
Print the compiled fusevm bytecode for
.I FILE
(the main chunk and every user function's chunk) and exit, instead of
running it.
.TP
.B \-\-dump\-tokens
Print the lexer token stream for
.I FILE
and exit.
.TP
.B \-\-dump\-ast
Print the parsed AST for
.I FILE
and exit.
.TP
.B \-\-disasm
Print a fusevm bytecode disassembly listing for
.I FILE
and exit.
.TP
.B \-\-lsp
Speak the Language Server Protocol over stdio.
.TP
.B \-\-dap
Speak the Debug Adapter Protocol over stdio, with source-line and function
breakpoints, stepping, call stack, locals, and expression evaluation.
.TP
.BR \-h ", " \-\-help
Print usage and exit.
.TP
.BR \-V ", " \-\-version
Print the version and exit.
.SH ARGUMENTS
.TP
.I FILE
The
.B .php
script to run. Omit to use
.B \-a
or
.BR \-r ,
or to read the script from stdin (non-interactive stdin with no
.I FILE
runs stdin as a script).
.PP
The entry point names the script, and the name is observable \(em every
diagnostic quotes it and
.I __FILE__
returns it. A
.I FILE
is its resolved path,
.B \-r
code is
.IR "Command line code" ,
and a script on stdin is
.IR "Standard input code" .
.TP
.I ARGV
Trailing arguments passed through to the running PHP program as
.BR $argv .
.SH LANGUAGE
Supported: scalars, variables and \fI$var\fR string interpolation, arithmetic
(\fI+ \- * / % **\fR), string concatenation (\fI.\fR), compound assignment,
increment/decrement (\fI++/\-\-\fR), loose and strict comparison
(\fI== != === !== < > <= >=\fR), logical operators (\fI&& || and or\fR), the
ternary operator (\fI?:\fR), indexed and associative arrays (literals, append
via \fI$a[]=\fR, index read/write), control flow (\fIif/elseif/else, while,
for, foreach, break, continue, return\fR), \fIexit\fR/\fIdie\fR (both spellings,
with and without parentheses and argument), and user-defined functions with
positional parameters and recursion.
.PP
A standard library is built in, including string functions (\fIstrlen,
str_repeat, strrev, substr, strpos, str_replace, strtoupper, strtolower,
ucfirst, trim, ltrim, rtrim\fR), array functions (\fIcount, implode, explode,
in_array, array_keys, array_values, array_push, range\fR), math functions
(\fIabs, floor, ceil, round, sqrt, max, min, intval, floatval\fR), type
introspection (\fIgettype, is_array, is_int, is_float, is_string, is_bool,
is_null, is_numeric\fR), and output formatting (\fIsprintf, printf, print_r,
var_dump\fR), and more.
.SH EXIT STATUS
0 on success. Whatever
.BR exit ()
or
.BR die ()
asked for when the program ended itself \(em an integer status modulo 256, so
\fIexit(300)\fR leaves 44 and \fIexit(\-1)\fR leaves 255, while a STRING argument
is printed and the status is 0. 255 on a parse error or a fatal error, which are
reported the way the PHP CLI reports them: the display copy on stdout
(\fIParse error: ...\fR / \fIFatal error: Uncaught ...\fR with a stack trace) and
a \fIPHP \fR-prefixed log copy on stderr \(em and 255 even when
.I error_reporting
is clear and neither copy was written. 1 on a failure with no PHP equivalent,
reported to stderr as \fIphp: <reason>\fR and nothing else.
.SH DIAGNOSTICS
Every diagnostic is written TWICE, under two independent ini flags, as the PHP
CLI defaults (\fIdisplay_errors=STDOUT\fR, \fIlog_errors=On\fR,
\fIhtml_errors=Off\fR) put them:
.I display_errors
puts the copy the program sees on \fBstdout\fR, interleaved with its own output
and inside any open
.BR ob_start ()
buffer, and
.I log_errors
puts a \fIPHP \fR-prefixed copy on \fBstderr\fR. Setting either to 0 with
.B \-d
suppresses that copy and only that copy.
.PP
Each diagnostic carries an
\fIE_*\fR level and is displayed only when that bit is set in the
\fIerror_reporting\fR mask \(em writable at run time by
.BR error_reporting ()
and
.BR ini_set (),
and at startup by
.BR \-d .
A fatal error (\fIE_ERROR\fR) and a parse error (\fIE_PARSE\fR) are masked by it
too, so \fIphp \-d error_reporting=0\fR runs an uncaught exception to completion
in silence.
The
.B @
operator suppresses locally without touching the mask, for the whole time its
operand runs \(em including diagnostics raised inside the library functions the
operand calls. It drops diagnostics only: an
.I Error
thrown while the operand runs still propagates.
.PP
A notice raised while the source is READ \(em \fIUsing ${var} in strings is
deprecated\fR \(em is emitted before the program's first output and regardless
of whether the code carrying it ever runs. Only the startup level applies to it.
.SH EXAMPLES
.TP
Run a script:
.B php script.php
.TP
Run a one-liner:
.B php \-r 'echo 6 * 7;'
.TP
Start the REPL:
.B php \-a
.TP
Inspect the compiled bytecode:
.B php \-\-dump\-bytecode script.php
.SH SEE ALSO
Project: https://github.com/MenkeTechnologies/phplang