PHP头条
热点:

PHP hack的使用技巧详解


PHP hack的使用方法是一个比较麻烦的过程。我们在这里给出的代码示例,希望能够作为大家在开发中的参考学习对象。这次讲的是使用PHP hack实现类似TAB VIEW的效果哦,的确麻烦些。

  • 如何运用PHP rmdir()函数删除目录
  • 同你分享PHP文件上传的一些注意事项
  • PHP垃圾代码的特征介绍
  • 教你如何正确运用PHP函数flush()
  • 详解PHP ob_start()函数的功能要点

PHP hack示例:

  1. < ?php  
  2. $tabs = array();  
  3. function tabs_header()  
  4. {  
  5. ?> 
  6. <style type="text/css"> 
  7. .tab {  
  8. border-bottom: 1px solid black;  
  9. text-align: center;  
  10. font-family: arial, verdana;  
  11. }  
  12. .tab-active {   
  13. border-left: 1px solid black;   
  14. border-top: 1px solid black;   
  15. border-right: 1px solid black;   
  16. text-align: center;   
  17. font-family: arial, verdana;   
  18. font-weight: bold;  
  19. }  
  20. .tab-content {   
  21. padding: 5px;   
  22. border-left: 1px solid black;   
  23. border-right: 1px solid black;   
  24. border-bottom: 1px solid black;  
  25. }   
  26. < /style>  

  1. <?php 
  2. }  
  3. function tabs_start()  
  4. {   
  5. ob_start();   
  6. }  
  7. function endtab()   
  8. {   
  9. global $tabs;  
  10. $text = ob_get_clean();  
  11. $tabs[ count( $tabs ) - 1 ][ 'text' ] = $text;  
  12. ob_start();  
  13. }  
  14. function tab( $title )   
  15. {  
  16. global $tabs;  
  17. if ( count( $tabs ) > 0 )  
  18. endtab();  
  19. $tabs []= array(  
  20. title => $title,  
  21. text => ""  
  22. );  
  23. }  
  24.  
  25. function tabs_end( )  
  26. {  
  27. global $tabs;  
  28. endtab( );  
  29. ob_end_clean( );  
  30. $index = 0;  
  31. if ( $_GET['tabindex'] )  
  32. $index = $_GET['tabindex'];  
  33. ?> 
  34. < table width="100%" cellspacing="0" cellpadding="0"> 
  35. < tr> 
  36. < ?php  
  37. $baseuri = $_SERVER['REQUEST_URI'];  
  38. $baseuri = preg_replace( "/\?.*$/", "", $baseuri );  
  39. $curindex = 0;  
  40. foreach( $tabs as $tab )  
  41. {  
  42. $class = "tab";  
  43. if ( $index == $curindex )  
  44. $class ="tab-active";  
  45. ?> 
  46. < td class="< ?php echo($class); ?>"> 
  47. < a href="< ?php echo( $baseuri."?tabindex=".$curindex ); ?>"> 
  48. < ?php echo( $tab['title'] ); ?> 
  49. < /a> 
  50. < /td> 
  51. < ?php  
  52. $curindex += 1;  
  53. }  
  54. ?> 
  55. < /tr> 
  56. < tr>< td class="tab-content" colspan="< ?php echo( count( $tabs ) + 1 ); ?>"> 
  57. < ?php echo( $tabs[$index ]['text'] ); ?> 
  58. < /td></tr> 
  59. < /table> 
  60. < ?php  
  61. }  
  62. ?> 

以上这一大段的代码就是有关PHP hack的具体实现方法。
 

www.phpzy.comtrue/php/12887.htmlTechArticlePHP hack的使用技巧详解 PHP hack的使用方法是一个比较麻烦的过程。我们在这里给出的代码示例,希望能够作为大家在开发中的参考学习对象。这次讲的是使用PHP hack实现类似TAB VIEW的效果...

相关文章

    暂无相关文章
相关频道:

PHP之友评论

今天推荐