Return to Snippet

Revision: 57451
at May 26, 2012 15:31 by xkeshav


Initial Code
<?php
/* this function is used to debug runtime variables 
if URL is like below :
http://localhost/project/admin/pages.php?go=modules/auction/add
then it will show the code of moudles/auction/add.php file 
simply by adding 'kode' at the end of the url
or it will display the source code of running file whether thii function is written on config.php file
*/
if (isset($_GET['kode'])) {    
    $d = debug_backtrace();
    $file = empty($_GET['go']) ? $d[1]['file'] : $_GET['go'].".php";    
    //__print(show_source($file));
    highlight_num($file);   
}

function highlight_num($file) 
{ 
  $lines = implode(range(1, count(file($file))), '<br />'); 
  $content = highlight_file($file, true); 
  
  echo ' 
    <style type="text/css"> 
        .num { 
        float: left; 
        color: gray; 
        font-size: 13px;    
        font-family: monospace; 
        text-align: right; 
        margin-right: 6pt; 
        padding-right: 6pt; 
        border-right: 1px solid gray;} 

        body {margin: 0px; margin-left: 5px;} 
        td {vertical-align: top;} 
        code {white-space: nowrap;} 
    </style>';    
    echo "<table><tr><td class=\"num\">\n$lines\n</td><td>\n$content\n</td></tr></table>"; 
} 
?>

Initial URL


Initial Description
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

Initial Title
function to see php code of any file

Initial Tags
php

Initial Language
PHP