src/GenSynth.php
public static function highlight_file($filename, $language = '', $return = false, $opts = 0)
    {
        if (is_bool($language)) {
            !is_int($return) ?: $opts = $return;
            $return = $language;
            $language = '';
        }
        elseif (is_int($language)) {
            $opts = $language;
            $language = '';
        }

        if (file_exists($filename) && is_readable($filename)) {
            $gs = new static($filename, '', $opts);

            if ($language == '') {
                $ext = pathinfo($filename, PATHINFO_EXTENSION);
                $language = $gs->get_language_name_from_extension($ext);
            }

            $gs->setLanguage($language);
            $s = $gs->parseCode();

            if ($gs->error()) {
                return false;
            }

            if ($return) {
                return '<code>' . $s . '</code>';
            }
            echo '<code>' . $s . '</code>';

            return true;
        }

        return false;
    }
public static function highlight_file($filename, $language = '', $return = false, $opts = 0)
    {
        if (is_bool($language)) {
            !is_int($return) ?: $opts = $return;
            $return = $language;
            $language = '';
        }
        elseif (is_int($language)) {
            $opts = $language;
            $language = '';
        }

        if (file_exists($filename) && is_readable($filename)) {
            $gs = new static($filename, '', $opts);

            if ($language == '') {
                $ext = pathinfo($filename, PATHINFO_EXTENSION);
                $language = $gs->get_language_name_from_extension($ext);
            }

            $gs->setLanguage($language);
            $s = $gs->parseCode();

            if ($gs->error()) {
                return false;
            }

            if ($return) {
                return '<code>' . $s . '</code>';
            }
            echo '<code>' . $s . '</code>';

            return true;
        }

        return false;
    }
public static function highlight_file ( $ filename , $ language = '' , $ return = false , $ opts = 0 ) { if ( is_bool ( $ language ) ) { ! is_int ( $ return ) ? : $ opts = $ return ; $ return = $ language ; $ language = '' ; } elseif ( is_int ( $ language ) ) { $ opts = $ language ; $ language = '' ; } if ( file_exists ( $ filename ) && is_readable ( $ filename ) ) { $ gs = new static ( $ filename , '' , $ opts ) ; if ( $ language == '' ) { $ ext = pathinfo ( $ filename , PATHINFO_EXTENSION ) ; $ language = $ gs -> get_language_name_from_extension ( $ ext ) ; } $ gs -> setLanguage ( $ language ) ; $ s = $ gs -> parseCode ( ) ; if ( $ gs -> error ( ) ) { return false ; } if ( $ return ) { return '<code>' . $ s . '</code>' ; } echo '<code>' . $ s . '</code>' ; return true ; } return false ; }
Easy way to highlight stuff. Behaves just like highlight_file

@param  string $filename the full filepath of the file to highlight
@param  string $language language to use
(will try to determine from extension if not provided)
[Default: ''] *Can be skipped*
@param  bool   $return   [Default: false] *Can be skipped*
@param  int    $opts     [Default: 0]

@return bool|string
Easy way to highlight stuff . Behaves just like highlight_file