function to see php code of any file


/ Published in: PHP
Save to your folder(s)

You can save this function in your common function file of config file, which must be included in the page which source code you want to see and simply add kode to the end of the URL and see the complete PHP code of that file on browser


Copy this code and paste it in your HTML
  1. <?php
  2. /* this function is used to debug runtime variables
  3. if URL is like below :
  4. http://localhost/project/admin/pages.php?go=modules/auction/add
  5. then it will show the code of moudles/auction/add.php file
  6. simply by adding 'kode' at the end of the url
  7. or it will display the source code of running file whether thii function is written on config.php file
  8. */
  9. if (isset($_GET['kode'])) {
  10. $file = empty($_GET['go']) ? $d[1]['file'] : $_GET['go'].".php";
  11. //__print(show_source($file));
  12. highlight_num($file);
  13. }
  14.  
  15. function highlight_num($file)
  16. {
  17. $lines = implode(range(1, count(file($file))), '<br />');
  18. $content = highlight_file($file, true);
  19.  
  20. echo '
  21. <style type="text/css">
  22. .num {
  23. float: left;
  24. color: gray;
  25. font-size: 13px;
  26. font-family: monospace;
  27. text-align: right;
  28. margin-right: 6pt;
  29. padding-right: 6pt;
  30. border-right: 1px solid gray;}
  31.  
  32. body {margin: 0px; margin-left: 5px;}
  33. td {vertical-align: top;}
  34. code {white-space: nowrap;}
  35. </style>';
  36. echo "<table><tr><td class=\"num\">\n$lines\n</td><td>\n$content\n</td></tr></table>";
  37. }
  38. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.