PHP stores values in a zval; integers go in long lval (32 or 64 bits depending on platform) while floats go in double dval (always 64-bit IEEE 754). This explains literal-to-zval conversion, precision loss past PHP_INT_MAX, and why a long survives a long->double->long round trip only below 2^53-1.
with 0 CommentA follow-up to debugging PHP core dumps: I improved the PHP 5.4 .gdbinit so that zbacktrace now shows the full function call stack including arguments, and printzv lets you expand arrays and objects. Includes the NTS workaround for inspecting objects from a core file.
with 0 CommentThanks to Ruilog again for his work on the second benchmark of Yaf 2.1. Yaf 2.1 did a lot of work to improve performance and reduce memory usage — here are the results, compared against other PHP frameworks.
with 0 CommentPHP 5.4 finally allows directly calling methods or accessing properties on a freshly instantiated object: (new Foo())->bar(). Laruence explains why this resisted a grammar patch for years (a shift/reduce conflict), why the parentheses are required, and Felipe's RFC that landed it.
with 0 CommentA deep dive into zend_alloc: how Zend MM splits memory into small vs large blocks, the small-block free_buckets pointer-packing trick (ZEND_MM_SMALL_FREE_BUCKET), and the large_free_buckets key-tree (indexed by the high bit of the size via bsr) with bitmap-assisted best-fit search. Written because existing references — including TIPI — got it wrong.
with 0 CommentArnaud's PHP 5.4 patch stops the ternary operator from copying its second/third operand every time — a big win when the operand is a large array. PHP already uses copy-on-write for normal assignment, but the ternary bypassed it; after the patch, array-copying overhead is eliminated.
with 0 CommentPHP 5.4's new zend signal mechanism (per Rasmus's RFC) lets signal masking work in any SAPI and improves performance. Built on Yahoo's deferred-signal idea, it registers handlers for SIGALRM/SIGINT etc. at startup and defers them via a depth counter (zend_signal_globals_t.depth) instead of repeated sigaction calls, plus a new zend_signal registration interface.
with 0 Commentjson_encode always mangles Chinese into unreadable \uXXXX escapes (and inflates the payload). PHP 5.4 adds the JSON_UNESCAPED_UNICODE flag so Chinese is emitted as-is. Also mentions the other new flags: JSON_BIGINT_AS_STRING, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES.
with 0 CommentPHP 5.4 lets you write binary literals directly in code (0b1101), handy for flag bits — previously you had to go through bin2dec with a string. Also new: hex2bin() converts a hex string straight into a binary data stream, replacing the old pack("H*") workaround.
with 0 Comment