欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

PHP hack的使用技巧详解

程序员文章站 2024-02-18 19:04:46
...

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. function tabs_end( )
  25. {
  26. global $tabs;
  27. endtab( );
  28. ob_end_clean( );
  29. $index = 0;
  30. if ( $_GET['tabindex'] )
  31. $index = $_GET['tabindex'];
  32. ?>
  33. table width="100%" cellspacing="0" cellpadding="0">
  34. tr>
  35. ?php
  36. $baseuri = $_SERVER['REQUEST_URI'];
  37. $baseuri = preg_replace( "/?.*$/", "", $baseuri );
  38. $curindex = 0;
  39. foreach( $tabs as $tab )
  40. {
  41. $class = "tab";
  42. if ( $index == $curindex )
  43. $class ="tab-active";
  44. ?>
  45. td class="">
  46. a href="?tabindex=".$curindex ); ?>">
  47. ?php echo( $tab['title'] ); ?>
  48. /a>
  49. /td>
  50. ?php
  51. $curindex += 1;
  52. }
  53. ?>
  54. /tr>
  55. tr> td class="tab-content" colspan="">
  56. ?php echo( $tabs[$index ]['text'] ); ?>
  57. /td>tr>
  58. /table>
  59. ?php
  60. }
  61. ?>

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