note 27661 modified in function.chr by didou

From: Date: Fri, 07 Nov 2003 11:23:33 +0000
Subject: note 27661 modified in function.chr by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-60069@lists.php.net to get a copy of this message
Want terminal colors in command line php scripts? This should take care of that. <? $_colors = array( 'LIGHT_RED' => "[1;31m", 'LIGHT_GREEN' => "[1;32m", 'YELLOW' => "[1;33m", 'LIGHT_BLUE' => "[1;34m", 'MAGENTA' => "[1;35m", 'LIGHT_CYAN' => "[1;36m", 'WHITE' => "[1;37m", 'NORMAL' => "[0m", 'BLACK' => "[0;30m", 'RED' => "[0;31m", 'GREEN' => "[0;32m", 'BROWN' => "[0;33m", 'BLUE' => "[0;34m", 'CYAN' => "[0;36m", 'BOLD' => "[1m", 'UNDERSCORE' => "[4m", 'REVERSE' => "[7m", ); function termcolored($text, $color="NORMAL", $back=1){ global $_colors; $out = $_colors["$color"]; if($out == ""){ $out = "[0m"; } if($back){ return chr(27)."$out$text".chr(27).chr(27)."[0m".chr(27); }else{ echo chr(27)."$out$text".chr(27).chr(27)."[0m".chr(27); }//fi }// end function echo termcolored("test\n", "BLUE"); ?> --was-- Want terminal colors in command line php scripts? This should take care of that. <? $_colors = array( LIGHT_RED => "[1;31m", LIGHT_GREEN => "[1;32m", YELLOW => "[1;33m", LIGHT_BLUE => "[1;34m", MAGENTA => "[1;35m", LIGHT_CYAN => "[1;36m", WHITE => "[1;37m", NORMAL => "[0m", BLACK => "[0;30m", RED => "[0;31m", GREEN => "[0;32m", BROWN => "[0;33m", BLUE => "[0;34m", CYAN => "[0;36m", BOLD => "[1m", UNDERSCORE => "[4m", REVERSE => "[7m", ); function termcolored($text, $color="NORMAL", $back=1){ global $_colors; $out = $_colors["$color"]; if($out == ""){ $out = "[0m"; } if($back){ return chr(27)."$out$text".chr(27).chr(27)."[0m".chr(27); }else{ echo chr(27)."$out$text".chr(27).chr(27)."[0m".chr(27); }//fi }// end function echo termcolored("test\n", "BLUE"); ?> http://www.php.net/manual/en/function.chr.php

« previous php.notes (#60069) next »