PHP is weakly typed, yet the Zend Engine is written in strongly typed C. This article shows how PHP represents every variable as a zval struct backed by a zvalue_value union, and how the type field decides which member of the union is read for integers, strings, arrays, objects and resources.
with 0 CommentSAPI is the layer that lets PHP exchange data with the outside world. This article walks through the simplest SAPI of all, the CGI SAPI, field by field through its sapi_module_struct, to show how a SAPI is wired into the Zend Engine.
with 0 CommentIn PHP there are two kinds of functions: zend_internal_function, supplied by an extension or the Zend/PHP kernel in C/C++ and directly executable, and zend_user_function, defined by the user in a PHP script and compiled by the ZE into an opcode array. This article looks at how the two differ at the ZE level, and why zend_internal_function, zend_op_array and zend_function can be safely cast to one another.
with 0 CommentAn introduction to what happens between writing a PHP script and running it: the lexer and parser, op codes and the op array, and how the Zend Engine's zend_execute walks the op array. It also shows how to inspect a script's op codes with the VLD extension.
with 0 CommentWhat an opcode is, and the four steps Zend goes through to run a PHP script: scanning into tokens, parsing into expressions, compiling into op_arrays, and executing them. Uses token_get_all output and the operand types IS_TMP_VAR, IS_VAR and IS_CV to show how the compiler rewrites your code.
with 0 CommentA step-by-step guide to exposing a C++ class as a PHP object from inside an extension: registering it as a resource, initializing the class entry in PHP_MINIT, and using ZEND_REGISTER_RESOURCE / zend_fetch_resource in the constructor and methods.
with 0 Comment