Documentation
¶
Overview ¶
Package compat implements PHP language surface that a script expects to be there rather than a library it calls: functions whose behaviour is defined by what the interpreter does, not by what they compute.
It is wired in by importing it, the way a program imports a database/sql driver:
import _ "github.com/titpetric/phpscript/stdlib/compat"
stdlib does that for you (see stdlib/imports.go). A host that wants a different set builds its Runtime without stdlib.
Output buffering ¶
PHP's ob_* family redirects everything echo would emit into a stack of in-memory buffers, and template engines lean on it: rendering to a string is "start a buffer, include the compiled template, take the contents". That is what MiniTPL\Template::get() is built on.
ob_start(); include $compiled; $html = ob_get_clean();
The buffers are pushed onto the runtime with runner.PushOutput, so the capture covers everything that reaches Runtime.Output: echo, inline HTML, and builtins that emit text of their own, such as die() with a message.
A function that reports "no buffer is active" returns false, as PHP does, rather than an empty string; the two are distinguishable with ===.
Regular expressions ¶
PHP's preg_* family is PCRE; Go's regexp is RE2, which cannot express backreferences or lookaround. regex.go compiles each pattern with whichever engine can express it, so both `\1` and a linear-time guarantee are available where they apply.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.