Change Colors In Windows Console from within PHP CLI Script
Posted: Sun Nov 01, 2009 7:34 am
Hello All,
My intention is to determine the outcome (calculated result) of a PHP script run using the PHP CLI; then I wish to set the text and background color of the windows console before displaying the result.
My PHP CLI script is running in a console window (and executes well), and I know that I can adjust the colors (text and background) using Color x,y (where x is the background color and y the text color eg. color 70 [light grey background with black text]. Well I have tested my example from a console window and from a .bat file with success.
I am just not sure from within PHP how to execute this console command in the current console window executing my PHP script?
I have tried things like:, but they don't seem to work.
Any assistance greatly appreciated.
Kind regards, Andrew
My intention is to determine the outcome (calculated result) of a PHP script run using the PHP CLI; then I wish to set the text and background color of the windows console before displaying the result.
My PHP CLI script is running in a console window (and executes well), and I know that I can adjust the colors (text and background) using Color x,y (where x is the background color and y the text color eg. color 70 [light grey background with black text]. Well I have tested my example from a console window and from a .bat file with success.
I am just not sure from within PHP how to execute this console command in the current console window executing my PHP script?
I have tried things like:
Code: Select all
$cmd = "color 25";
shell_exec($cmd);
Any assistance greatly appreciated.
Kind regards, Andrew