PHP hack示例:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"></span><span class="tag-name">php</span><span> </span></span></li> <li><span>} </span></li> <li class="alt"><span>function tabs_start() </span></li> <li><span>{ </span></li> <li class="alt"><span>ob_start(); </span></li> <li><span>} </span></li> <li class="alt"><span>function endtab() </span></li> <li><span>{ </span></li> <li class="alt"><span>global $tabs; </span></li> <li> <span>$</span><span class="attribute">text</span><span> = </span><span class="attribute-value">ob_get_clean</span><span>(); </span> </li> <li class="alt"><span>$tabs[ count( $tabs ) - 1 ][ 'text' ] = $text; </span></li> <li><span>ob_start(); </span></li> <li class="alt"><span>} </span></li> <li><span>function tab( $title ) </span></li> <li class="alt"><span>{ </span></li> <li><span>global $tabs; </span></li> <li class="alt"> <span>if ( count( $tabs ) </span><span class="tag">></span><span> 0 ) </span> </li> <li><span>endtab(); </span></li> <li class="alt"><span>$tabs []= array( </span></li> <li> <span class="attribute">title</span><span> =</span><span class="tag">></span><span> $title, </span> </li> <li class="alt"> <span class="attribute">text</span><span> =</span><span class="tag">></span><span> "" </span> </li> <li><span>); </span></li> <li class="alt"><span>} </span></li> <li><span> </span></li> <li class="alt"><span>function tabs_end( ) </span></li> <li><span>{ </span></li> <li class="alt"><span>global $tabs; </span></li> <li><span>endtab( ); </span></li> <li class="alt"><span>ob_end_clean( ); </span></li> <li> <span>$</span><span class="attribute">index</span><span> = </span><span class="attribute-value">0</span><span>; </span> </li> <li class="alt"><span>if ( $_GET['tabindex'] ) </span></li> <li> <span>$</span><span class="attribute">index</span><span> = $_GET['tabindex']; </span> </li> <li class="alt"> <span class="tag">?></span><span> </span> </li> <li><span class="tag"><span> </span><span class="tag-name">table</span><span> </span><span class="attribute">width</span><span>=</span><span class="attribute-value">"100%"</span><span> </span><span class="attribute">cellspacing</span><span>=</span><span class="attribute-value">"0"</span><span> </span><span class="attribute">cellpadding</span><span>=</span><span class="attribute-value">"0"</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span class="tag"><span> </span><span class="tag-name">tr</span><span class="tag">></span><span> </span></span></li> <li><span class="tag"><span> ?php </span></span></li> <li class="alt"> <span>$</span><span class="attribute">baseuri</span><span> = $_SERVER['REQUEST_URI']; </span> </li> <li> <span>$</span><span class="attribute">baseuri</span><span> = </span><span class="attribute-value">preg_replace</span><span>( "/?.*$/", "", $baseuri ); </span> </li> <li class="alt"> <span>$</span><span class="attribute">curindex</span><span> = </span><span class="attribute-value">0</span><span>; </span> </li> <li><span>foreach( $tabs as $tab ) </span></li> <li class="alt"><span>{ </span></li> <li> <span>$</span><span class="attribute">class</span><span> = </span><span class="attribute-value">"tab"</span><span>; </span> </li> <li class="alt"> <span>if ( $</span><span class="attribute">index</span><span> == $curindex ) </span> </li> <li> <span>$</span><span class="attribute">class</span><span> =</span><span class="attribute-value">"tab-active"</span><span>; </span> </li> <li class="alt"> <span class="tag">?></span><span> </span> </li> <li><span class="tag"><span> </span><span class="tag-name">td</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">""</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span class="tag"><span> </span><span class="tag-name">a</span><span> </span><span class="attribute">href</span><span>=</span><span class="attribute-value">"<span>?</span><span class="attribute">tabindex</span><span>=</span><span class="attribute-value">".$curindex ); ?>"</span><span class="tag">></span><span> </span></span></span></li> <li><span class="tag"><span> ?php echo( $tab['title'] ); </span><span class="tag">?></span><span> </span></span></li> <li class="alt"><span class="tag"><span> /a</span><span class="tag">></span><span> </span></span></li> <li><span class="tag"><span> /td</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span class="tag"><span> ?php </span></span></li> <li><span>$curindex += 1; </span></li> <li class="alt"><span>} </span></li> <li> <span class="tag">?></span><span> </span> </li> <li class="alt"><span class="tag"><span> /tr</span><span class="tag">></span><span> </span></span></li> <li><span class="tag"><span> </span><span class="tag-name">tr</span><span class="tag">></span><span class="tag"><span> </span><span class="tag-name">td</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">"tab-content"</span><span> </span><span class="attribute">colspan</span><span>=</span><span class="attribute-value">""</span><span class="tag">></span><span> </span></span></span></li> <li class="alt"><span class="tag"><span> ?php echo( $tabs[$index ]['text'] ); </span><span class="tag">?></span><span> </span></span></li> <li><span class="tag"><span> /td</span><span class="tag">></span><span class="tag"></span><span class="tag-name">tr</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span class="tag"><span> /table</span><span class="tag">></span><span> </span></span></li> <li><span class="tag"><span> ?php </span></span></li> <li class="alt"><span>} </span></li> <li> <span class="tag">?></span><span> </span> </li> </ol>
以上这一大段的代码就是有关PHP hack的具体实现方法。