public function getFileCode($file, $line, $range = 20)
    {
        $code = file($file);
        $half = (int)($range / 2);

        $start = $line - $half;
        0 > $start && $start = 0;

        $total = count($code);
        $end = $line + $half;
        $total < $end && $end = $total;

        $len = strlen($end);

        array_unshift($code, null);
        $content = '';
        for ($i = $start; $i < $end; $i++) {
            $temp = str_pad($i, $len, 0, STR_PAD_LEFT) . ':  ' . $code[$i];
            if ($line != $i) {
                $content .= htmlspecialchars($temp, ENT_QUOTES);
            } else {
                $content .= '<strong class="text-danger">' . htmlspecialchars($temp, ENT_QUOTES) . '</strong>';
            }
        }

        return $content;
    }
public function getFileCode($file, $line, $range = 20)
    {
        $code = file($file);
        $half = (int)($range / 2);

        $start = $line - $half;
        0 > $start && $start = 0;

        $total = count($code);
        $end = $line + $half;
        $total < $end && $end = $total;

        $len = strlen($end);

        array_unshift($code, null);
        $content = '';
        for ($i = $start; $i < $end; $i++) {
            $temp = str_pad($i, $len, 0, STR_PAD_LEFT) . ':  ' . $code[$i];
            if ($line != $i) {
                $content .= htmlspecialchars($temp, ENT_QUOTES);
            } else {
                $content .= '<strong class="text-danger">' . htmlspecialchars($temp, ENT_QUOTES) . '</strong>';
            }
        }

        return $content;
    }
public function getFileCode ( $ file , $ line , $ range = 20 ) { $ code = file ( $ file ) ; $ half = ( int ) ( $ range / 2 ) ; $ start = $ line - $ half ; 0 > $ start && $ start = 0 ; $ total = count ( $ code ) ; $ end = $ line + $ half ; $ total < $ end && $ end = $ total ; $ len = strlen ( $ end ) ; array_unshift ( $ code , null ) ; $ content = '' ; for ( $ i = $ start ; $ i < $ end ; $ i ++ ) { $ temp = str_pad ( $ i , $ len , 0 , STR_PAD_LEFT ) . ':  ' . $ code [ $ i ] ; if ( $ line != $ i ) { $ content .= htmlspecialchars ( $ temp , ENT_QUOTES ) ; } else { $ content .= '<strong class="text-danger">' . htmlspecialchars ( $ temp , ENT_QUOTES ) . '</strong>' ; } } return $ content ; }
Get file code in specified range

@param  string $file The file name
@param  int $line The file line
@param  int $range The line range
@return string
Get file code in specified range