-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.php
More file actions
31 lines (24 loc) · 773 Bytes
/
example.php
File metadata and controls
31 lines (24 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/*
* This file is part of the CLI-SYNTAX package.
*
* (c) Jitendra Adhikari <jiten.adhikary@gmail.com>
* <https://github.com/adhocore>
*
* Licensed under MIT license.
*/
use Ahc\CliSyntax\Exporter;
use Ahc\CliSyntax\Highlighter;
require_once __DIR__ . '/src/Pretty.php';
require_once __DIR__ . '/src/Exporter.php';
require_once __DIR__ . '/src/Highlighter.php';
// Highlight code
echo (new Highlighter("<?php echo 'Hello world!'; ?>" . PHP_EOL))
->highlight();
// Highlight file
echo Highlighter::for(__FILE__)->highlight();
// Export highlighted file as image
Exporter::for(__FILE__)->export(__DIR__ . '/example.png');
// Magic string works too:
echo new Highlighter('<?php echo "Hello Again!";' . PHP_EOL);
// echo Highlighter::for(__FILE__);