PHP code example of malenki / ansi

1. Go to this page and download the library: Download malenki/ansi 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/ */

    

malenki / ansi example snippets


use Malenki\Ansi;

$a = new Ansi('Hello World!');
echo $a->red->bold->underline; // you get string in red color, bold and underline! :)

$a = new Ansi();
$a->fg('red');
echo $a->v('Hello World!'); //in red
echo $a->v('Hello World again!'); //in red too


echo (new Ansi('Hello World!'))->red->bold->underline;

echo (new Ansi('Hello World!'))->red->bold->underline->bg_blue;

echo Ansi::parse('You can <bold>parse <cyan>string</cyan></bold> containing <red>some tags</red> to have <underline><yellow>some effects</yellow></underline> too!');
 php
use Malenki\Ansi;

$a = new Ansi('Hello World!');
echo $a->fg('red');
 php
use Malenki\Ansi;
echo (new Ansi('Hello World!'))->fg('red')->bg('yellow');
 php
use Malenki\Ansi;
echo (new Ansi('Hello World!'))->fg('red')->bg('yellow')->bold();
 php
use Malenki\Ansi;
$str = (new Ansi('Hello World!'))->fg('red')->bg('yellow')->bold()->render();