PHP code example of phpexperts / tempest-highlight-api
1. Go to this page and download the library: Download phpexperts/tempest-highlight-api 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/ */
phpexperts / tempest-highlight-api example snippets
use PHPExperts\RESTSpeaker\NoAuth;
use PHPExperts\RESTSpeaker\RESTSpeaker;
$url = 'https://highlight.phpexperts.pro';
$highlighter = new class(new NoAuth(), $url) extends RESTSpeaker {
public function highlight(string $language, string $text): string
{
$result = $this->post('/highlight', [
'lang' => $language,
'text' => $text
]);
if ($this->getLastStatusCode() === 400) {
throw new \RuntimeException($result);
}
return $result;
}
};
echo $highlighter->highlight('PHP', 'echo "Hello, World!\n";');