이 기간 동안 너무 바빠서 한 달 동안 블로그를 하지 못했습니다. 시간이 나면 개발 중에 겪은 문제를 기록해 보고 싶습니다.
PHP가 Android apk 패키지를 업로드할 때 Android apk 패키지의 정보를 가져와야 합니다
<?<span style="color: #000000;">php </span><span style="color: #008000;">/*</span><span style="color: #008000;">解析安卓apk包中的压缩XML文件,还原和读取XML内容 依赖功能:需要PHP的ZIP包函数支持。</span><span style="color: #008000;">*/</span> <span style="color: #0000ff;">include</span>('./Apkparser.php'<span style="color: #000000;">); </span><span style="color: #800080;">$appObj</span> = <span style="color: #0000ff;">new</span><span style="color: #000000;"> Apkparser(); </span><span style="color: #800080;">$targetFile</span> = a.apk;<span style="color: #008000;">//</span><span style="color: #008000;">apk所在的路径地址</span> <span style="color: #800080;">$res</span> = <span style="color: #800080;">$appObj</span>->open(<span style="color: #800080;">$targetFile</span><span style="color: #000000;">); </span><span style="color: #800080;">$appObj</span>->getAppName(); <span style="color: #008000;">//</span><span style="color: #008000;"> 应用名称</span> <span style="color: #800080;">$appObj</span>->getPackage(); <span style="color: #008000;">//</span><span style="color: #008000;"> 应用包名</span> <span style="color: #800080;">$appObj</span>->getVersionName(); <span style="color: #008000;">//</span><span style="color: #008000;"> 版本名称</span> <span style="color: #800080;">$appObj</span>->getVersionCode(); <span style="color: #008000;">//</span><span style="color: #008000;"> 版本代码</span> ?>
다음은 Apkparser 클래스 패키지입니다. 아래 코드를 복사하여 Apkparser.php로 저장하여 위 코드를 실행합니다
<?<span style="color: #000000;">php </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> ApkParser{ </span><span style="color: #008000;">//</span><span style="color: #008000;">---------------------- // 公共函数,供外部调用 //----------------------</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> open(<span style="color: #800080;">$apk_file</span>, <span style="color: #800080;">$xml_file</span>='AndroidManifest.xml'<span style="color: #000000;">){ </span><span style="color: #800080;">$zip</span> = <span style="color: #0000ff;">new</span><span style="color: #000000;"> \ZipArchive; </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$zip</span>->open(<span style="color: #800080;">$apk_file</span>) === <span style="color: #0000ff;">TRUE</span><span style="color: #000000;">) { </span><span style="color: #800080;">$xml</span> = <span style="color: #800080;">$zip</span>->getFromName(<span style="color: #800080;">$xml_file</span><span style="color: #000000;">); </span><span style="color: #800080;">$zip</span>-><span style="color: #000000;">close(); </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$xml</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->parseString(<span style="color: #800080;">$xml</span><span style="color: #000000;">); }</span><span style="color: #0000ff;">catch</span> (<span style="color: #0000ff;">Exception</span> <span style="color: #800080;">$e</span><span style="color: #000000;">){ } } } </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> parseString(<span style="color: #800080;">$xml</span><span style="color: #000000;">){ </span><span style="color: #800080;">$this</span>->xml = <span style="color: #800080;">$xml</span><span style="color: #000000;">; </span><span style="color: #800080;">$this</span>->length = <span style="color: #008080;">strlen</span>(<span style="color: #800080;">$xml</span><span style="color: #000000;">); </span><span style="color: #800080;">$this</span>->root = <span style="color: #800080;">$this</span>->parseBlock(self::<span style="color: #000000;">AXML_FILE); </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> getXML(<span style="color: #800080;">$node</span>=<span style="color: #0000ff;">NULL</span>, <span style="color: #800080;">$lv</span>=-1<span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$lv</span> == -1) <span style="color: #800080;">$node</span> = <span style="color: #800080;">$this</span>-><span style="color: #000000;">root; </span><span style="color: #0000ff;">if</span> (!<span style="color: #800080;">$node</span>) <span style="color: #0000ff;">return</span> ''<span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$node</span>['type'] == self::END_TAG) <span style="color: #800080;">$lv</span>--<span style="color: #000000;">; </span><span style="color: #800080;">$xml</span> = @(<span style="color: #800080;">$node</span>['line'] == 0 || <span style="color: #800080;">$node</span>['line'] == <span style="color: #800080;">$this</span>->line) ? '' : "\n".<span style="color: #008080;">str_repeat</span>(' ', <span style="color: #800080;">$lv</span><span style="color: #000000;">); </span><span style="color: #800080;">$xml</span> .= <span style="color: #800080;">$node</span>['tag'<span style="color: #000000;">]; </span><span style="color: #800080;">$this</span>->line = @<span style="color: #800080;">$node</span>['line'<span style="color: #000000;">]; </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$node</span>['child'] <span style="color: #0000ff;">as</span> <span style="color: #800080;">$c</span><span style="color: #000000;">){ </span><span style="color: #800080;">$xml</span> .= <span style="color: #800080;">$this</span>->getXML(<span style="color: #800080;">$c</span>, <span style="color: #800080;">$lv</span>+1<span style="color: #000000;">); } </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$xml</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getPackage(){ </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->getAttribute('manifest', 'package'<span style="color: #000000;">); } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getVersionName(){ </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->getAttribute('manifest', 'android:versionName'<span style="color: #000000;">); } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getVersionCode(){ </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->getAttribute('manifest', 'android:versionCode'<span style="color: #000000;">); } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getAppName(){ </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->getAttribute('manifest/application', 'android:name'<span style="color: #000000;">); } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getMainActivity(){ </span><span style="color: #0000ff;">for</span> (<span style="color: #800080;">$id</span>=0; <span style="color: #0000ff;">true</span>; <span style="color: #800080;">$id</span>++<span style="color: #000000;">){ </span><span style="color: #800080;">$act</span> = <span style="color: #800080;">$this</span>->getAttribute("manifest/application/activity[{<span style="color: #800080;">$id</span>}]/intent-filter/action", 'android:name'<span style="color: #000000;">); </span><span style="color: #0000ff;">if</span> (!<span style="color: #800080;">$act</span>) <span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$act</span> == 'android.intent.action.MAIN') <span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->getActivity(<span style="color: #800080;">$id</span><span style="color: #000000;">); } </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> getActivity(<span style="color: #800080;">$idx</span>=0<span style="color: #000000;">){ </span><span style="color: #800080;">$idx</span> = <span style="color: #008080;">intval</span>(<span style="color: #800080;">$idx</span><span style="color: #000000;">); </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->getAttribute("manifest/application/activity[{<span style="color: #800080;">$idx</span>}]", 'android:name'<span style="color: #000000;">); } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> getAttribute(<span style="color: #800080;">$path</span>, <span style="color: #800080;">$name</span><span style="color: #000000;">){ </span><span style="color: #800080;">$r</span> = <span style="color: #800080;">$this</span>->getElement(<span style="color: #800080;">$path</span><span style="color: #000000;">); </span><span style="color: #0000ff;">if</span> (<span style="color: #008080;">is_null</span>(<span style="color: #800080;">$r</span>)) <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$r</span>['attrs'<span style="color: #000000;">])){ </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$r</span>['attrs'] <span style="color: #0000ff;">as</span> <span style="color: #800080;">$a</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$a</span>['ns_name'] == <span style="color: #800080;">$name</span>) <span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->getAttributeValue(<span style="color: #800080;">$a</span><span style="color: #000000;">); } } </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #000000;">; } </span><span style="color: #008000;">//</span><span style="color: #008000;">---------------------- // 类型常量定义 //----------------------</span> <span style="color: #0000ff;">const</span> AXML_FILE = 0x00080003<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> STRING_BLOCK = 0x001C0001<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> RESOURCEIDS = 0x00080180<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> START_NAMESPACE = 0x00100100<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> END_NAMESPACE = 0x00100101<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> START_TAG = 0x00100102<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> END_TAG = 0x00100103<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TEXT = 0x00100104<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_NULL =0<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_REFERENCE =1<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_ATTRIBUTE =2<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_STRING =3<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_FLOAT =4<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_DIMENSION =5<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_FRACTION =6<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_INT_DEC =16<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_INT_HEX =17<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_INT_BOOLEAN =18<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_INT_COLOR_ARGB8 =28<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_INT_COLOR_RGB8 =29<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_INT_COLOR_ARGB4 =30<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> TYPE_INT_COLOR_RGB4 =31<span style="color: #000000;">; </span><span style="color: #0000ff;">const</span> UNIT_MASK = 15<span style="color: #000000;">; </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #800080;">$RADIX_MULTS</span> = <span style="color: #0000ff;">array</span>(0.00390625, 3.051758E-005, 1.192093E-007, 4.656613E-010<span style="color: #000000;">); </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #800080;">$DIMENSION_UNITS</span> = <span style="color: #0000ff;">array</span>("px","dip","sp","pt","in","mm","",""<span style="color: #000000;">); </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #800080;">$FRACTION_UNITS</span> = <span style="color: #0000ff;">array</span>("%","%p","","","","","",""<span style="color: #000000;">); </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$xml</span>=''<span style="color: #000000;">; </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$length</span> = 0<span style="color: #000000;">; </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$stringCount</span> = 0<span style="color: #000000;">; </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$styleCount</span> = 0<span style="color: #000000;">; </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$stringTab</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$styleTab</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$resourceIDs</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$ns</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$cur_ns</span> = <span style="color: #0000ff;">NULL</span><span style="color: #000000;">; </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$root</span> = <span style="color: #0000ff;">NULL</span><span style="color: #000000;">; </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$line</span> = 0<span style="color: #000000;">; </span><span style="color: #008000;">//</span><span style="color: #008000;">---------------------- // 内部私有函数 //----------------------</span> <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> getElement(<span style="color: #800080;">$path</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (!<span style="color: #800080;">$this</span>->root) <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #000000;">; </span><span style="color: #800080;">$ps</span> = <span style="color: #008080;">explode</span>('/', <span style="color: #800080;">$path</span><span style="color: #000000;">); </span><span style="color: #800080;">$r</span> = <span style="color: #800080;">$this</span>-><span style="color: #000000;">root; </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$ps</span> <span style="color: #0000ff;">as</span> <span style="color: #800080;">$v</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (<span style="color: #008080;">preg_match</span>('/([^\[]+)\[([0-9]+)\]$/', <span style="color: #800080;">$v</span>, <span style="color: #800080;">$ms</span><span style="color: #000000;">)){ </span><span style="color: #800080;">$v</span> = <span style="color: #800080;">$ms</span>[1<span style="color: #000000;">]; </span><span style="color: #800080;">$off</span> = <span style="color: #800080;">$ms</span>[2<span style="color: #000000;">]; }</span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { </span><span style="color: #800080;">$off</span> = 0<span style="color: #000000;">; } </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$r</span>['child'] <span style="color: #0000ff;">as</span> <span style="color: #800080;">$c</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$c</span>['type'] == self::START_TAG && <span style="color: #800080;">$c</span>['ns_name'] == <span style="color: #800080;">$v</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$off</span> == 0<span style="color: #000000;">){ </span><span style="color: #800080;">$r</span> = <span style="color: #800080;">$c</span>; <span style="color: #0000ff;">continue</span> 2<span style="color: #000000;">; }</span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { </span><span style="color: #800080;">$off</span>--<span style="color: #000000;">; } } } </span><span style="color: #008000;">//</span><span style="color: #008000;"> 没有找到节点</span> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$r</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> parseBlock(<span style="color: #800080;">$need</span> = 0<span style="color: #000000;">){ </span><span style="color: #800080;">$o</span> = 0<span style="color: #000000;">; </span><span style="color: #800080;">$type</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$need</span> && <span style="color: #800080;">$type</span> != <span style="color: #800080;">$need</span>) <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">Exception</span>('Block Type Error', 1<span style="color: #000000;">); </span><span style="color: #800080;">$size</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$size</span> < 8 || <span style="color: #800080;">$size</span> > <span style="color: #800080;">$this</span>->length) <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">Exception</span>('Block Size Error', 2<span style="color: #000000;">); </span><span style="color: #800080;">$left</span> = <span style="color: #800080;">$this</span>->length - <span style="color: #800080;">$size</span><span style="color: #000000;">; </span><span style="color: #800080;">$props</span> = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">switch</span> (<span style="color: #800080;">$type</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">case</span> self::AXML_FILE: <span style="color: #800080;">$props</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">( </span>'line' => 0, 'tag' => '<?xml version="1.0" encoding="utf-8"?>'<span style="color: #000000;"> ); </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">case</span> self::STRING_BLOCK: <span style="color: #800080;">$this</span>->stringCount = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$this</span>->styleCount = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$o</span> += 4<span style="color: #000000;">; </span><span style="color: #800080;">$strOffset</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$styOffset</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$strListOffset</span> = <span style="color: #800080;">$this</span>->get32array(<span style="color: #800080;">$o</span>, <span style="color: #800080;">$this</span>-><span style="color: #000000;">stringCount); </span><span style="color: #800080;">$styListOffset</span> = <span style="color: #800080;">$this</span>->get32array(<span style="color: #800080;">$o</span>, <span style="color: #800080;">$this</span>-><span style="color: #000000;">styleCount); </span><span style="color: #800080;">$this</span>->stringTab = <span style="color: #800080;">$this</span>->stringCount > 0 ? <span style="color: #800080;">$this</span>->getStringTab(<span style="color: #800080;">$strOffset</span>, <span style="color: #800080;">$strListOffset</span>) : <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #800080;">$this</span>->styleTab = <span style="color: #800080;">$this</span>->styleCount > 0 ? <span style="color: #800080;">$this</span>->getStringTab(<span style="color: #800080;">$styOffset</span>, <span style="color: #800080;">$styListOffset</span>) : <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #800080;">$o</span> = <span style="color: #800080;">$size</span><span style="color: #000000;">; </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">case</span> self::RESOURCEIDS: <span style="color: #800080;">$count</span> = <span style="color: #800080;">$size</span> / 4 - 2<span style="color: #000000;">; </span><span style="color: #800080;">$this</span>->resourceIDs = <span style="color: #800080;">$this</span>->get32array(<span style="color: #800080;">$o</span>, <span style="color: #800080;">$count</span><span style="color: #000000;">); </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">case</span> self::START_NAMESPACE: <span style="color: #800080;">$o</span> += 8<span style="color: #000000;">; </span><span style="color: #800080;">$prefix</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$uri</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$this</span>-><span style="color: #000000;">cur_ns)){ </span><span style="color: #800080;">$this</span>->cur_ns = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #800080;">$this</span>->ns[] = &<span style="color: #800080;">$this</span>-><span style="color: #000000;">cur_ns; } </span><span style="color: #800080;">$this</span>->cur_ns[<span style="color: #800080;">$uri</span>] = <span style="color: #800080;">$prefix</span><span style="color: #000000;">; </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">case</span> self::END_NAMESPACE: <span style="color: #800080;">$o</span> += 8<span style="color: #000000;">; </span><span style="color: #800080;">$prefix</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$uri</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$this</span>->cur_ns)) <span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">unset</span>(<span style="color: #800080;">$this</span>->cur_ns[<span style="color: #800080;">$uri</span><span style="color: #000000;">]); </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">case</span> self::START_TAG: <span style="color: #800080;">$line</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$o</span> += 4<span style="color: #000000;">; </span><span style="color: #800080;">$attrs</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #800080;">$props</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">( </span>'line' => <span style="color: #800080;">$line</span>, 'ns' => <span style="color: #800080;">$this</span>->getNameSpace(<span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span>)), 'name' => <span style="color: #800080;">$this</span>->getString(<span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span>)), 'flag' => <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span>), 'count' => <span style="color: #800080;">$this</span>->get16(<span style="color: #800080;">$o</span>), 'id' => <span style="color: #800080;">$this</span>->get16(<span style="color: #800080;">$o</span>)-1, 'class' => <span style="color: #800080;">$this</span>->get16(<span style="color: #800080;">$o</span>)-1, 'style' => <span style="color: #800080;">$this</span>->get16(<span style="color: #800080;">$o</span>)-1, 'attrs' => &<span style="color: #800080;">$attrs</span><span style="color: #000000;"> ); </span><span style="color: #800080;">$props</span>['ns_name'] = <span style="color: #800080;">$props</span>['ns'].<span style="color: #800080;">$props</span>['name'<span style="color: #000000;">]; </span><span style="color: #0000ff;">for</span> (<span style="color: #800080;">$i</span>=0; <span style="color: #800080;">$i</span> < <span style="color: #800080;">$props</span>['count']; <span style="color: #800080;">$i</span>++<span style="color: #000000;">){ </span><span style="color: #800080;">$a</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">( </span>'ns' => <span style="color: #800080;">$this</span>->getNameSpace(<span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span>)), 'name' => <span style="color: #800080;">$this</span>->getString(<span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span>)), 'val_str' => <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span>), 'val_type' => <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span>), 'val_data' => <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">) ); </span><span style="color: #800080;">$a</span>['ns_name'] = <span style="color: #800080;">$a</span>['ns'].<span style="color: #800080;">$a</span>['name'<span style="color: #000000;">]; </span><span style="color: #800080;">$a</span>['val_type'] >>= 24<span style="color: #000000;">; </span><span style="color: #800080;">$attrs</span>[] = <span style="color: #800080;">$a</span><span style="color: #000000;">; } </span><span style="color: #008000;">//</span><span style="color: #008000;"> 处理TAG字符串</span> <span style="color: #800080;">$tag</span> = "<{<span style="color: #800080;">$props</span>['ns_name']}"<span style="color: #000000;">; </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$this</span>->cur_ns <span style="color: #0000ff;">as</span> <span style="color: #800080;">$uri</span> => <span style="color: #800080;">$prefix</span><span style="color: #000000;">){ </span><span style="color: #800080;">$uri</span> = <span style="color: #800080;">$this</span>->getString(<span style="color: #800080;">$uri</span><span style="color: #000000;">); </span><span style="color: #800080;">$prefix</span> = <span style="color: #800080;">$this</span>->getString(<span style="color: #800080;">$prefix</span><span style="color: #000000;">); </span><span style="color: #800080;">$tag</span> .= " xmlns:{<span style="color: #800080;">$prefix</span>}=\"{<span style="color: #800080;">$uri</span>}\""<span style="color: #000000;">; } </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$props</span>['attrs'] <span style="color: #0000ff;">as</span> <span style="color: #800080;">$a</span><span style="color: #000000;">){ </span><span style="color: #800080;">$tag</span> .= " {<span style="color: #800080;">$a</span>['ns_name']}=\"". <span style="color: #800080;">$this</span>->getAttributeValue(<span style="color: #800080;">$a</span>). '"'<span style="color: #000000;">; } </span><span style="color: #800080;">$tag</span> .= '>'<span style="color: #000000;">; </span><span style="color: #800080;">$props</span>['tag'] = <span style="color: #800080;">$tag</span><span style="color: #000000;">; </span><span style="color: #0000ff;">unset</span>(<span style="color: #800080;">$this</span>-><span style="color: #000000;">cur_ns); </span><span style="color: #800080;">$this</span>->cur_ns = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #800080;">$this</span>->ns[] = &<span style="color: #800080;">$this</span>-><span style="color: #000000;">cur_ns; </span><span style="color: #800080;">$left</span> = -1<span style="color: #000000;">; </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">case</span> self::END_TAG: <span style="color: #800080;">$line</span> = <span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$o</span> += 4<span style="color: #000000;">; </span><span style="color: #800080;">$props</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">( </span>'line' => <span style="color: #800080;">$line</span>, 'ns' => <span style="color: #800080;">$this</span>->getNameSpace(<span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span>)), 'name' => <span style="color: #800080;">$this</span>->getString(<span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">)) ); </span><span style="color: #800080;">$props</span>['ns_name'] = <span style="color: #800080;">$props</span>['ns'].<span style="color: #800080;">$props</span>['name'<span style="color: #000000;">]; </span><span style="color: #800080;">$props</span>['tag'] = "</{<span style="color: #800080;">$props</span>['ns_name']}>"<span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (<span style="color: #008080;">count</span>(<span style="color: #800080;">$this</span>->ns) > 1<span style="color: #000000;">){ </span><span style="color: #008080;">array_pop</span>(<span style="color: #800080;">$this</span>-><span style="color: #000000;">ns); </span><span style="color: #0000ff;">unset</span>(<span style="color: #800080;">$this</span>-><span style="color: #000000;">cur_ns); </span><span style="color: #800080;">$this</span>->cur_ns = <span style="color: #008080;">array_pop</span>(<span style="color: #800080;">$this</span>-><span style="color: #000000;">ns); </span><span style="color: #800080;">$this</span>->ns[] = &<span style="color: #800080;">$this</span>-><span style="color: #000000;">cur_ns; } </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">case</span> self::TEXT: <span style="color: #800080;">$o</span> += 8<span style="color: #000000;">; </span><span style="color: #800080;">$props</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">( </span>'tag' => <span style="color: #800080;">$this</span>->getString(<span style="color: #800080;">$this</span>->get32(<span style="color: #800080;">$o</span><span style="color: #000000;">)) ); </span><span style="color: #800080;">$o</span> += 8<span style="color: #000000;">; </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; </span><span style="color: #0000ff;">default</span>: <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">Exception</span>('Block Type Error', 3<span style="color: #000000;">); </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; } </span><span style="color: #800080;">$this</span>->skip(<span style="color: #800080;">$o</span><span style="color: #000000;">); </span><span style="color: #800080;">$child</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">while</span> (<span style="color: #800080;">$this</span>->length > <span style="color: #800080;">$left</span><span style="color: #000000;">){ </span><span style="color: #800080;">$c</span> = <span style="color: #800080;">$this</span>-><span style="color: #000000;">parseBlock(); </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$props</span> && <span style="color: #800080;">$c</span>) <span style="color: #800080;">$child</span>[] = <span style="color: #800080;">$c</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$left</span> == -1 && <span style="color: #800080;">$c</span>['type'] == self::<span style="color: #000000;">END_TAG){ </span><span style="color: #800080;">$left</span> = <span style="color: #800080;">$this</span>-><span style="color: #000000;">length; </span><span style="color: #0000ff;">break</span><span style="color: #000000;">; } } </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$this</span>->length != <span style="color: #800080;">$left</span>) <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">Exception</span>('Block Overflow Error', 4<span style="color: #000000;">); </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$props</span><span style="color: #000000;">){ </span><span style="color: #800080;">$props</span>['type'] = <span style="color: #800080;">$type</span><span style="color: #000000;">; </span><span style="color: #800080;">$props</span>['size'] = <span style="color: #800080;">$size</span><span style="color: #000000;">; </span><span style="color: #800080;">$props</span>['child'] = <span style="color: #800080;">$child</span><span style="color: #000000;">; </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$props</span><span style="color: #000000;">; }</span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">; } } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> getAttributeValue(<span style="color: #800080;">$a</span><span style="color: #000000;">){ </span><span style="color: #800080;">$type</span> = &<span style="color: #800080;">$a</span>['val_type'<span style="color: #000000;">]; </span><span style="color: #800080;">$data</span> = &<span style="color: #800080;">$a</span>['val_data'<span style="color: #000000;">]; </span><span style="color: #0000ff;">switch</span> (<span style="color: #800080;">$type</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">case</span> self::TYPE_STRING: <span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->getString(<span style="color: #800080;">$a</span>['val_str'<span style="color: #000000;">]); </span><span style="color: #0000ff;">case</span> self::TYPE_ATTRIBUTE: <span style="color: #0000ff;">return</span> <span style="color: #008080;">sprintf</span>('?%s%08X', self::_getPackage(<span style="color: #800080;">$data</span>), <span style="color: #800080;">$data</span><span style="color: #000000;">); </span><span style="color: #0000ff;">case</span> self::TYPE_REFERENCE: <span style="color: #0000ff;">return</span> <span style="color: #008080;">sprintf</span>('@%s%08X', self::_getPackage(<span style="color: #800080;">$data</span>), <span style="color: #800080;">$data</span><span style="color: #000000;">); </span><span style="color: #0000ff;">case</span> self::TYPE_INT_HEX: <span style="color: #0000ff;">return</span> <span style="color: #008080;">sprintf</span>('0x%08X', <span style="color: #800080;">$data</span><span style="color: #000000;">); </span><span style="color: #0000ff;">case</span> self::TYPE_INT_BOOLEAN: <span style="color: #0000ff;">return</span> (<span style="color: #800080;">$data</span> != 0 ? 'true' : 'false'<span style="color: #000000;">); </span><span style="color: #0000ff;">case</span> self::TYPE_INT_COLOR_ARGB8: <span style="color: #0000ff;">case</span> self::TYPE_INT_COLOR_RGB8: <span style="color: #0000ff;">case</span> self::TYPE_INT_COLOR_ARGB4: <span style="color: #0000ff;">case</span> self::TYPE_INT_COLOR_RGB4: <span style="color: #0000ff;">return</span> <span style="color: #008080;">sprintf</span>('#%08X', <span style="color: #800080;">$data</span><span style="color: #000000;">); </span><span style="color: #0000ff;">case</span> self::TYPE_DIMENSION: <span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->_complexToFloat(<span style="color: #800080;">$data</span>).self::<span style="color: #800080;">$DIMENSION_UNITS</span>[<span style="color: #800080;">$data</span> & self::<span style="color: #000000;">UNIT_MASK]; </span><span style="color: #0000ff;">case</span> self::TYPE_FRACTION: <span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->_complexToFloat(<span style="color: #800080;">$data</span>).self::<span style="color: #800080;">$FRACTION_UNITS</span>[<span style="color: #800080;">$data</span> & self::<span style="color: #000000;">UNIT_MASK]; </span><span style="color: #0000ff;">case</span> self::TYPE_FLOAT: <span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->_int2float(<span style="color: #800080;">$data</span><span style="color: #000000;">); } </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$type</span> >=self::TYPE_INT_DEC && <span style="color: #800080;">$type</span> < self::<span style="color: #000000;">TYPE_INT_COLOR_ARGB8){ </span><span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">string</span>)<span style="color: #800080;">$data</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">return</span> <span style="color: #008080;">sprintf</span>('<0x%X, type 0x%02X>', <span style="color: #800080;">$data</span>, <span style="color: #800080;">$type</span><span style="color: #000000;">); } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> _complexToFloat(<span style="color: #800080;">$data</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">float</span>)(<span style="color: #800080;">$data</span> & 0xFFFFFF00) * self::<span style="color: #800080;">$RADIX_MULTS</span>[(<span style="color: #800080;">$data</span>>>4) & 3<span style="color: #000000;">]; } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> _int2float(<span style="color: #800080;">$v</span><span style="color: #000000;">) { </span><span style="color: #800080;">$x</span> = (<span style="color: #800080;">$v</span> & ((1 << 23) - 1)) + (1 << 23) * (<span style="color: #800080;">$v</span> >> 31 | 1<span style="color: #000000;">); </span><span style="color: #800080;">$exp</span> = (<span style="color: #800080;">$v</span> >> 23 & 0xFF) - 127<span style="color: #000000;">; </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$x</span> * <span style="color: #008080;">pow</span>(2, <span style="color: #800080;">$exp</span> - 23<span style="color: #000000;">); } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> _getPackage(<span style="color: #800080;">$data</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">return</span> (<span style="color: #800080;">$data</span> >> 24 == 1) ? 'android:' : ''<span style="color: #000000;">; } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> getStringTab(<span style="color: #800080;">$base</span>, <span style="color: #800080;">$list</span><span style="color: #000000;">){ </span><span style="color: #800080;">$tab</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$list</span> <span style="color: #0000ff;">as</span> <span style="color: #800080;">$off</span><span style="color: #000000;">){ </span><span style="color: #800080;">$off</span> += <span style="color: #800080;">$base</span><span style="color: #000000;">; </span><span style="color: #800080;">$len</span> = <span style="color: #800080;">$this</span>->get16(<span style="color: #800080;">$off</span><span style="color: #000000;">); </span><span style="color: #800080;">$mask</span> = (<span style="color: #800080;">$len</span> >> 0x8) & 0xFF<span style="color: #000000;">; </span><span style="color: #800080;">$len</span> = <span style="color: #800080;">$len</span> & 0xFF<span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$len</span> == <span style="color: #800080;">$mask</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$off</span> + <span style="color: #800080;">$len</span> > <span style="color: #800080;">$this</span>->length) <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">Exception</span>('String Table Overflow', 11<span style="color: #000000;">); </span><span style="color: #800080;">$tab</span>[] = <span style="color: #008080;">substr</span>(<span style="color: #800080;">$this</span>->xml, <span style="color: #800080;">$off</span>, <span style="color: #800080;">$len</span><span style="color: #000000;">); }</span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$off</span> + <span style="color: #800080;">$len</span> * 2 > <span style="color: #800080;">$this</span>->length) <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">Exception</span>('String Table Overflow', 11<span style="color: #000000;">); </span><span style="color: #800080;">$str</span> = <span style="color: #008080;">substr</span>(<span style="color: #800080;">$this</span>->xml, <span style="color: #800080;">$off</span>, <span style="color: #800080;">$len</span> * 2<span style="color: #000000;">); </span><span style="color: #800080;">$tab</span>[] = mb_convert_encoding(<span style="color: #800080;">$str</span>, 'UTF-8', 'UCS-2LE'<span style="color: #000000;">); } } </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$tab</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> getString(<span style="color: #800080;">$id</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$id</span> > -1 && <span style="color: #800080;">$id</span> < <span style="color: #800080;">$this</span>-><span style="color: #000000;">stringCount){ </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>->stringTab[<span style="color: #800080;">$id</span><span style="color: #000000;">]; }</span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { </span><span style="color: #0000ff;">return</span> ''<span style="color: #000000;">; } } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> getNameSpace(<span style="color: #800080;">$uri</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">for</span> (<span style="color: #800080;">$i</span>=<span style="color: #008080;">count</span>(<span style="color: #800080;">$this</span>->ns); <span style="color: #800080;">$i</span> > 0<span style="color: #000000;">; ){ </span><span style="color: #800080;">$ns</span> = <span style="color: #800080;">$this</span>->ns[--<span style="color: #800080;">$i</span><span style="color: #000000;">]; </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$ns</span>[<span style="color: #800080;">$uri</span><span style="color: #000000;">])){ </span><span style="color: #800080;">$ns</span> = <span style="color: #800080;">$this</span>->getString(<span style="color: #800080;">$ns</span>[<span style="color: #800080;">$uri</span><span style="color: #000000;">]); </span><span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$ns</span>)) <span style="color: #800080;">$ns</span> .= ':'<span style="color: #000000;">; </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$ns</span><span style="color: #000000;">; } } </span><span style="color: #0000ff;">return</span> ''<span style="color: #000000;">; } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> get32(&<span style="color: #800080;">$off</span><span style="color: #000000;">){ </span><span style="color: #800080;">$int</span> = <span style="color: #008080;">unpack</span>('V', <span style="color: #008080;">substr</span>(<span style="color: #800080;">$this</span>->xml, <span style="color: #800080;">$off</span>, 4<span style="color: #000000;">)); </span><span style="color: #800080;">$off</span> += 4<span style="color: #000000;">; </span><span style="color: #0000ff;">return</span> <span style="color: #008080;">array_shift</span>(<span style="color: #800080;">$int</span><span style="color: #000000;">); } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> get32array(&<span style="color: #800080;">$off</span>, <span style="color: #800080;">$size</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$size</span> <= 0) <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #000000;">; </span><span style="color: #800080;">$arr</span> = <span style="color: #008080;">unpack</span>('V*', <span style="color: #008080;">substr</span>(<span style="color: #800080;">$this</span>->xml, <span style="color: #800080;">$off</span>, 4 * <span style="color: #800080;">$size</span><span style="color: #000000;">)); </span><span style="color: #0000ff;">if</span> (<span style="color: #008080;">count</span>(<span style="color: #800080;">$arr</span>) != <span style="color: #800080;">$size</span>) <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">Exception</span>('Array Size Error', 10<span style="color: #000000;">); </span><span style="color: #800080;">$off</span> += 4 * <span style="color: #800080;">$size</span><span style="color: #000000;">; </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$arr</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> get16(&<span style="color: #800080;">$off</span><span style="color: #000000;">){ </span><span style="color: #800080;">$int</span> = <span style="color: #008080;">unpack</span>('v', <span style="color: #008080;">substr</span>(<span style="color: #800080;">$this</span>->xml, <span style="color: #800080;">$off</span>, 2<span style="color: #000000;">)); </span><span style="color: #800080;">$off</span> += 2<span style="color: #000000;">; </span><span style="color: #0000ff;">return</span> <span style="color: #008080;">array_shift</span>(<span style="color: #800080;">$int</span><span style="color: #000000;">); } </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">function</span> skip(<span style="color: #800080;">$size</span><span style="color: #000000;">){ </span><span style="color: #800080;">$this</span>->xml = <span style="color: #008080;">substr</span>(<span style="color: #800080;">$this</span>->xml, <span style="color: #800080;">$size</span><span style="color: #000000;">); </span><span style="color: #800080;">$this</span>->length -= <span style="color: #800080;">$size</span><span style="color: #000000;">; } } </span>?>