PHP hack的使用技巧详解

开发 后端
对于初学者来说,PHP hack的使用是一个比较复杂,难以掌握的知识点。下面我们将以一段代码示例来具体讲解PHP hack的使用技巧。

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

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的具体实现方法。
 

责任编辑:曹凯 来源: 博客园
相关推荐

2014-11-03 10:14:22

2009-12-07 10:54:46

PHP uploade

2009-12-02 13:53:12

PHP使用技巧

2009-09-04 10:45:18

MyEclipse使用

2023-02-03 08:21:55

2009-11-30 09:21:39

PHP函数rmdir(

2009-11-25 17:28:26

PHP对话

2009-12-07 16:59:53

PHP匹配颜色函数

2009-11-23 18:47:51

PHP中用header

2009-12-01 19:23:22

PHP缓存技术

2009-12-01 10:50:45

PHP函数requir

2009-12-02 16:04:44

PHP fsockop

2009-11-27 09:30:58

PHP函数mb_str

2023-02-01 08:22:37

2009-08-17 08:42:48

LinuxScreen命令使用技巧

2009-12-04 15:43:03

PHP JSON扩展

2009-11-30 17:43:54

PHP split()

2009-12-01 14:26:19

PHP函数ob_sta

2009-11-25 13:39:36

PHP函数sizeof

2009-12-07 14:29:08

PHP array_w
点赞
收藏

51CTO技术栈公众号