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><code class="language-php" data-file="php-highlight/examples/index.php">
<?php
abstract class AbstractClass
{
/**
* Our abstract method only needs to define the
$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";
</code></pre>
';
$highlighter = (new Highlighter($text, ObsidianTheme::TITLE))
->showLineNumbers(true)
->showActionPanel(true);
echo $highlighter->parse();