PHP code example of twoixter / ansicolors

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

    

twoixter / ansicolors example snippets




    $color = new \MyNamespace\ANSISuperClass::color_factory(\MyNamespace::ANSI_RED_COLOR);
    echo $color->generate_ansi_codes("E");


 echo ansi::red()."this is red".ansi::reset(); 

 echo ansi::red("this is red");  # No need to reset 

<? echo ansi::Red_on_white("Yep!"); 



	# Define some new color names
    ansi::define("error", "Red_on_white");
    ansi::define("success", "Green");

	# Definitions can be recursive
    ansi::define("default", "success");

	# Use the new named colors
	echo ansi::success("The file has been copied successfully!");
    echo ansi::error("Watch out! Something went wrong...");


$ php myscript.php | less
$ php myscript.php > output_file.txt