Skip to content

Outputs or returns html markup for a syntax highlighted version of the given PHP code

License

Notifications You must be signed in to change notification settings

Ghostff/php_prettify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Prettify

Creates a syntax highlighted version of the given PHP code.

# PHP 8
composer require ghostff/php_prettify

# Older PHP version
composer require ghostff/php_prettify:5.4.093021
composer require ghostff/php_prettify:7.0.093021
<?php

use PhpPrettify\Highlight;

echo '<pre>', (new Highlight)->render('$name = "foobar"'), '</pre>';

Highlighting a file

<?php

use PhpPrettify\Highlight;

echo '<pre>', (new Highlight)
        ->setTheme('bittr')                             // Sets code highlight theme.
        ->setStyle('body {margin:0;padding:0}')         // Append css to default to style.
        ->setHighlight(22, ['style' => 'color:red'])    // Add html attributes to selected line(tr).
        ->showLineNumber(1, false)                      // Show line number starting from line 1 and prevent selection of line number.
        ->render('code.txt', true),
    '</pre>';

alt tag

About

Outputs or returns html markup for a syntax highlighted version of the given PHP code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published