ghostff/php_prettify

将给定的PHP代码创建为语法高亮版本。

安装: 5

依赖: 0

建议者: 0

安全: 0

星标: 12

关注者: 3

分支: 2

开放问题: 3

语言:HTML

dev-master 2021-12-04 02:44 UTC

This package is auto-updated.

Last update: 2024-09-04 09:15:32 UTC


README

将给定的PHP代码创建为语法高亮版本。

# 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>';

高亮文件

<?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