« back to index

How to dissassemble a PHP script

Useful if you want to check performance, catch a bug in the engine, etc.

 
svn co svn://svn.xdebug.org/svn/php/vld/trunk vld
cd vld
phpize && ./configure && make && make install
php -dextension=vld.so -dvld.active=1 script.php

You will get something like this:

 
function name: fibonacci
number of ops:  38
compiled vars:  !0 = $nr, !1 = $cache, !2 = $r
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   4     0  >   RECV                                                     1
   5     1      FETCH_W                      global lock         $0      'cache'
         2      ASSIGN_REF                                               !1, $0
   7     3      ZEND_ISSET_ISEMPTY_DIM_OBJ                    1  ~1      !1, !0
         4    > JMPZ                                                     ~1, ->8
   8     5  >   FETCH_DIM_R                                      $2      !1, !0
         6    > RETURN                                                   $2
   9     7*     JMP                                                      ->8
  11     8  >   CASE                                             ~3      !0, 0
         9    > JMPZ                                                     ~3, ->12
...

Source: http://talks.php.net/show/php-secrets-phptek8/5 and http://talks.php.net/show/php-secrets-phptek8/6