+ -
当前位置:首页 → 问答吧 → PHP源代码分析:PHP脚本OPCODE查看工具[v0.07]

PHP源代码分析:PHP脚本OPCODE查看工具[v0.07]

时间:2008-11-14

来源:互联网

发布一个可以查看PHP脚本编译后的OPCODE的查看工具,一个DOS小程序,使用PHP 5.3.0alpha2 版本。不知道什么是OPCODE,可以在本版搜索相关贴子。

PHP OPcode转储工具。将PHP源文件转换成相应的OPcode, 输出到指定的文件中。
本程序目前只能在Windows系列操作系统命令行(DOS)下使用。

最新的版本请至 http://www.phpinternals.com下载。
使用方法:

直接在DOS命令行下输入opdump命令即可查看使用说明。

opdump [options] [-o<output_filename>] <php_script_file>
-e 输出扩展格式opcode (EXT_STMT_*)
-d 输出DECLARE_INHERITED_DELAYED_CLASS指令
-o 参数如果不指定,直接以源文件再加上后缀".op"作为输出文件名。

最简单的使用方法是在DOS命令行下输入如下命令:
opdump uri.php
即可生成 uri.php.op文件

压缩包中文件:
opdump.exe  --- 主程序
php5ts.dll --- PHP 5.3.0alpha2 DLL
uri.php    --- 演示用PHP文件
uri.php.op  --- 输出结果
readme.txt  --- 本文件
CHANGELOG  --- 程序更新日志

opdump_0.0.7.rar (1.89 MB)

下载次数:141

2008-11-14 15:01

作者: Altair   发布时间: 2008-11-14

1: <?php
    2:
    3: /**
    4:  * Zend Framework
    5:  *
    6:  * LICENSE
    7:  *
    8:  * This source file is subject to the new BSD license that is bundled
    9:  * with this package in the file LICENSE.txt.
   10:  * It is also available through the world-wide-web at this URL:
   11:  * http://framework.zend.com/license/new-bsd
   12:  * If you did not receive a copy of the license and are unable to
   13:  * obtain it through the world-wide-web, please send an email
   14:  * to [email protected] so we can send you a copy immediately.
   15:  *
   16:  * @category   Zend
   17:  * @package    Zend_Uri
   18:  * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
   19:  * @license    http://framework.zend.com/license/new-bsd     New BSD License
   20:  * @version    $Id: Uri.php 8064 2008-02-16 10:58:39Z thomas $
   21:  */
   22:
   23: /**
   24:  * @see Zend_Loader
   25:  */
   26: require_once 'Zend/Loader.php';
            0  INCLUDE_OR_EVAL     'Zend/Loader.php', REQUIRE_ONCE
   27:
   28: /**
   29:  * @category   Zend
   30:  * @package    Zend_Uri
   31:  * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
   32:  * @license    http://framework.zend.com/license/new-bsd     New BSD License
   33:  */
   34: abstract class Zend_Uri
   35: {
            1  NOP                 
   36:     /**
   37:      * Scheme of this URI (http, ftp, etc.)
   38:      * @var string
   39:      */
   40:     protected $_scheme = '';
   41:
   42:     /**
   43:      * Return a string representation of this URI.
   44:      *
   45:      * @see     getUri()
   46:      * @return  string
   47:      */
   48:     public function __toString()
   49:     {
   50:         return $this->getUri();
            0  INIT_METHOD_CALL    'getUri' =>RES[]        
            1  DO_FCALL_BY_NAME     [extval:0]
            2  RETURN              $1
   51:     }
            3* RETURN              null
   52:
   53:     /**
   54:      * Convenience function, checks that a $uri string is well-formed
   55:      * by validating it but not returning an object.  Returns TRUE if
   56:      * $uri is a well-formed URI, or FALSE otherwise.
   57:      *
   58:      * @param string $uri
   59:      * @return boolean
   60:      */
   61:     public static function check($uri)
            0  RECV                1
   62:     {
   63:         try {
   64:             $uri = self::factory($uri);
            1  FETCH_CLASS         
            2  INIT_STATIC_METHOD_CALL  $0, 'factory' =>RES[]        
            3  SEND_VAR            !0
            4  DO_FCALL_BY_NAME     [extval:1]
            5  ASSIGN              !0, $1
   65:         } catch (Exception $e) {
            6  JMP                 ->10
            7* FETCH_CLASS         'Exception' =>RES[:3]      
            8* CATCH               $3, !1 =>RES[]         [extval:10]
   66:             return false;
            9* RETURN              false
   67:         }
   68:
   69:         return $uri->valid();
           10  INIT_METHOD_CALL    !0, 'valid' =>RES[]        
           11  DO_FCALL_BY_NAME     [extval:0]
           12  RETURN              $5
   70:     }
           13* RETURN              null
   71:
   72:     /**
   73:      * Create a new Zend_Uri object for a URI.  If building a new URI, then $uri should contain
   74:      * only the scheme (http, ftp, etc).  Otherwise, supply $uri with the complete URI.
   75:      *
   76:      * @param string $uri
   77:      * @throws Zend_Uri_Exception
   78:      * @return Zend_Uri
   79:      */
   80:     public static function factory($uri = 'http')
            0  RECV_INIT           1, 'http'
   81:     {
   82:         /**
   83:          * Separate the scheme from the scheme-specific parts
   84:          * @link http://www.faqs.org/rfcs/rfc2396.html
   85:          */
   86:         $uri = explode(':', $uri, 2);
            1  SEND_VAL            ':'
            2  SEND_VAR            !0
            3  SEND_VAL            2
            4  DO_FCALL            'explode' [extval:3]
            5  ASSIGN              !0, $0
   87:         $scheme = strtolower($uri[0]);
            6  FETCH_DIM_R         !0, 0 =>RES[$2]      
            7  SEND_VAR            $2
            8  DO_FCALL            'strtolower' [extval:1]
            9  ASSIGN              !1, $3
   88:         $schemeSpecific = isset($uri[1]) ? $uri[1] : '';
           10  ISSET_ISEMPTY_DIM_OBJ  !0, 1 =>RES[~5]       [extval:1]
           11  JMPZ                ~5, ->15
           12  FETCH_DIM_R         !0, 1 =>RES[$6]      
           13  QM_ASSIGN           $6 =>RES[~7]      
           14  JMP                 ->16
           15  QM_ASSIGN           '' =>RES[~7]      
           16  ASSIGN              !2, ~7
   89:
   90:         if (!strlen($scheme)) {
           17  SEND_VAR            !1
           18  DO_FCALL            'strlen' [extval:1]
           19  BOOL_NOT            $9 =>RES[~10]     
           20  JMPZ                ~10, ->28
   91:             require_once 'Zend/Uri/Exception.php';   
           21  INCLUDE_OR_EVAL     'Zend/Uri/Exception.php', REQUIRE_ONCE
   92:             throw new Zend_Uri_Exception('An empty string was supplied for the scheme');
           22  FETCH_CLASS         'Zend_Uri_Exception' =>RES[:12]     
           23  NEW                 :12 =>RES[$13]     
           24  SEND_VAL            'An empty string was supplied for the scheme'
           25  DO_FCALL_BY_NAME     [extval:1]
           26  THROW               $13 =>RES[]         [extval:0]
   93:         }
           27* JMP                 ->28
   94:
   95:         // Security check: $scheme is used to load a class file, so only alphanumerics are allowed.
   96:         if (!ctype_alnum($scheme)) {
           28  SEND_VAR            !1
           29  DO_FCALL            'ctype_alnum' [extval:1]
           30  BOOL_NOT            $15 =>RES[~16]     
           31  JMPZ                ~16, ->39
   97:             require_once 'Zend/Uri/Exception.php';   
           32  INCLUDE_OR_EVAL     'Zend/Uri/Exception.php', REQUIRE_ONCE
   98:             throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted');
           33  FETCH_CLASS         'Zend_Uri_Exception' =>RES[:18]     
           34  NEW                 :18 =>RES[$19]     
           35  SEND_VAL            'Illegal scheme supplied, only alphanumeric characters are permitted'
           36  DO_FCALL_BY_NAME     [extval:1]
           37  THROW               $19 =>RES[]         [extval:0]
   99:         }
           38* JMP                 ->39
  100:
  101:         /**
  102:          * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the
  103:          * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown.
  104:          */
  105:         switch ($scheme) {
  106:             case 'http':
           39  CASE                !1, 'http' =>RES[~21]     
           40  JMPZ                ~21, ->42
  107:             case 'https':
           41  JMP                 ->44
           42  CASE                !1, 'https' =>RES[~21]     
           43  JMPZ                ~21, ->47
  108:                 $className = 'Zend_Uri_Http';
           44  ASSIGN              !3, 'Zend_Uri_Http'
  109:                 break;
           45  BRK                 1 =>RES[]        
  110:             case 'mailto':
           46* JMP                 ->49
           47  CASE                !1, 'mailto' =>RES[~21]     
           48  JMPZ                ~21, ->50
  111:                 // @todo
  112:             default:
           49  JMP                 ->51
           50  JMP                 ->61
  113:                 require_once 'Zend/Uri/Exception.php';   
           51  INCLUDE_OR_EVAL     'Zend/Uri/Exception.php', REQUIRE_ONCE
  114:                 throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported");
           52  FETCH_CLASS         'Zend_Uri_Exception' =>RES[:24]     
           53  NEW                 :24 =>RES[$25]     
           54  ADD_STRING          'Scheme "' =>RES[~26]     
           55  ADD_VAR             ~26, !1 =>RES[~26]     
           56  ADD_STRING          ~26, '" is not supported' =>RES[~26]     
           57  SEND_VAL            ~26
           58  DO_FCALL_BY_NAME     [extval:1]
           59  THROW               $25 =>RES[]         [extval:0]
  115:         }
           60* JMP                 ->62
           61  JMP                 ->51
  116:         Zend_Loader::loadClass($className);
           62  INIT_STATIC_METHOD_CALL  'Zend_Loader', 'loadClass' =>RES[]        
           63  OP_DATA             'zend_loader::loadclass' =>RES[]        
           64  SEND_VAR            !3
           65  DO_FCALL_BY_NAME     [extval:1]
  117:         return new $className($scheme, $schemeSpecific);
           66  FETCH_CLASS         !3 =>RES[:29]     
           67  NEW                 :29 =>RES[$30]     
           68  SEND_VAR            !1
           69  SEND_VAR            !2
           70  DO_FCALL_BY_NAME     [extval:2]
           71  RETURN              $30
  118:
  119:     }
           72* RETURN              null
  120:
  121:     /**
  122:      * Get the URI's scheme
  123:      *
  124:      * @return string|false Scheme or false if no scheme is set.
  125:      */
  126:     public function getScheme()
  127:     {
  128:         if (!empty($this->_scheme)) {
            0  ISSET_ISEMPTY_PROP_OBJ  '_scheme' =>RES[~0]      
            1  BOOL_NOT            ~0 =>RES[~1]      
            2  JMPZ                ~1, ->6
  129:             return $this->_scheme;
            3  FETCH_OBJ_R         '_scheme' =>RES[$2]      
            4  RETURN              $2
  130:         } else {
            5* JMP                 ->7
  131:             return false;
            6  RETURN              false
  132:         }
  133:     }
            7* RETURN              null
  134:
  135:     /******************************************************************************
  136:      * Abstract Methods
  137:      *****************************************************************************/
  138:
  139:     /**
  140:      * Zend_Uri and its subclasses cannot be instantiated directly.
  141:      * Use Zend_Uri::factory() to return a new Zend_Uri object.
  142:      */
  143:     abstract protected function __construct($scheme, $schemeSpecific = '');
            0  RECV                1
            1  RECV_INIT           2, ''
            2  RAISE_ABSTRACT_ERROR   =>RES[]        
            3  RETURN              null
  144:
  145:     /**
  146:      * Return a string representation of this URI.
  147:      *
  148:      * @return string
  149:      */
  150:     abstract public function getUri();
            0  RAISE_ABSTRACT_ERROR   =>RES[]        
            1  RETURN              null
  151:
  152:     /**
  153:      * Returns TRUE if this URI is valid, or FALSE otherwise.
  154:      *
  155:      * @return boolean
  156:      */
  157:     abstract public function valid();
            0  RAISE_ABSTRACT_ERROR   =>RES[]        
            1  RETURN              null
  158: }

作者: Altair   发布时间: 2008-11-14

谢谢LZ,有一疑问,这到底在开发中有什么用?
一般工作就是开发功能,用不上啊。

作者: 0hudu   发布时间: 2008-11-14