forked from kevinlebrun/colors.php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
executable file
·38 lines (30 loc) · 927 Bytes
/
example.php
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
32
33
34
35
36
37
38
#!/usr/bin/env php
<?php
require_once './lib/Colors/Exception.php';
require_once './lib/Colors/InvalidArgumentException.php';
require_once './lib/Colors/Color.php';
$c = new \Colors\Color();
// highlight('green') === bg('green') === bg_green()
// white() === fg('white')
echo $c('Hello World!')->white()->bold()->highlight('green') . PHP_EOL;
// using some magic
echo $c('Hello World!')->white->bold->bg_green . PHP_EOL;
// create your own theme
$c->setTheme(
array(
'welcome' => array('white', 'bg_green'),
'bye' => 'blue',
)
);
echo $c('Hello World!')->welcome->bold . PHP_EOL;
echo $c('Bye!')->bye . PHP_EOL;
// use style tags
$text = <<<EOF
1 : <welcome>Hello <bold>World!</bold></welcome>
2 : <bye>Bye!</bye>
EOF;
echo $c($text)->colorize() . PHP_EOL;
// use standard API
$message = $c->apply('bold', $c->white('Hello World!'));
echo $message . PHP_EOL;
echo $c->clean($message) . PHP_EOL;