PHP code example of demyanovs / php-highlight

1. Go to this page and download the library: Download demyanovs/php-highlight library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

demyanovs / php-highlight example snippets




emyanovs\PHPHighlight\Highlighter;
use Demyanovs\PHPHighlight\Themes\ObsidianTheme;

$text = '
<pre data-file="php-highlight/examples/index.php" data-lang="php">
&lt;?php
abstract class AbstractClass
{
    /**
     * Our abstract method only needs to define the tring
    {
        $prefix = "";
        if ($name === "Pacman") {
            $prefix = "Mr.";
        } elseif ($name === "Pacwoman") {
            $prefix = "Mrs.";
        } else {
            
        }
        
        return $prefix . " " . $name;
    }
}

$class = new ConcreteClass;
echo $class->prefixName("Pacman"), "\n";
echo $class->prefixName("Pacwoman"), "\n";
</pre>
';

$highlighter = new Highlighter($text, ObsidianTheme::TITLE);
// Configuration
$highlighter->showLineNumbers(true);
$highlighter->showActionPanel(true);
echo $highlighter->parse();

$highlighter->showLineNumbers(true);
$highlighter->showActionPanel(true);

$defaultColorSchemaDto = new DefaultColorSchemaDto(...);
$PHPColorSchemaDto = new PHPColorSchemaDto(...);
$XMLColorSchemaDto = new XMLColorSchemaDto(...);

$myTheme = new Theme(
    'myThemeTitle',
    $defaultColorSchemaDto,
    $PHPColorSchemaDto,
    $XMLColorSchemaDto
);

$highlighter = new Highlighter($text, 'myThemeTitle', [$myTheme]);
bash
$ composer