Skip to content

Commit c72638d

Browse files
committed
Readme
1 parent 8c006a4 commit c72638d

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PHPHighlight is a PHP library for highlighting syntax that can be easily configu
55
The library parses the text, finds the tag \<pre>, read attributes (data-lang, data-file, data-theme), and for this reason decides how to highlight the syntax of this block.
66
Supports style customization.
77

8-
Here is an example of styling:
8+
Here are examples of styling:
99

1010
<img width="757" height="309" src="https://codingwar.com/sites/default/files/images/phphighlight2.png">
1111

@@ -23,10 +23,49 @@ See examples here [index.php](../master/examples/index.php)
2323
```php
2424
<?php
2525

26-
require_once '../vendor/autoload.php';
26+
require_once 'vendor/autoload.php';
2727

2828
use Demyanovs\PHPHighlight\Highlighter;
2929

30+
$text = '
31+
<pre data-file="php-highlight/examples/index.php" data-lang="php">
32+
abstract class AbstractClass
33+
{
34+
/**
35+
* Our abstract method only needs to define the required arguments
36+
* @param string $name
37+
* @return string
38+
*/
39+
abstract protected function prefixName(string $name): string;
40+
}
41+
42+
class ConcreteClass extends AbstractClass
43+
{
44+
/**
45+
* Our child class may define optional arguments not in the parent\'s signature
46+
* @param string $name
47+
* @param string $separator
48+
* @return string
49+
*/
50+
public function prefixName(string $name, string $separator = ".") : string
51+
{
52+
if ($name == "Pacman") {
53+
$prefix = "Mr";
54+
} elseif ($name == "Pacwoman") {
55+
$prefix = "Mrs";
56+
} else {
57+
$prefix = "";
58+
}
59+
return "{$prefix}{$separator} {$name}";
60+
}
61+
}
62+
63+
$class = new ConcreteClass;
64+
echo $class->prefixName("Pacman"), "\n";
65+
echo $class->prefixName("Pacwoman"), "\n";
66+
</pre>
67+
';
68+
3069
$highlighter = new Highlighter($text, 'railscasts');
3170
// Configuration
3271
$highlighter->setShowLineNumbers(true);

0 commit comments

Comments
 (0)