Instead of hard-coded sequences, you should use a library such as PHP Ncurses which will be more likely to work on more terminal types
The example from ncurses_color_set:
<?php
ncurses_init();
// If the terminal supports colors, initialize and set active color
if (ncurses_has_colors()) {
ncurses_start_color();
ncurses_init_pair(1, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLUE);
ncurses_color_set(1);
}
// Write a string at specified location
ncurses_mvaddstr(10, 10, "Hello world! Yellow on blue text!");
// Flush output to screen
ncurses_refresh();
ncurses_end();
?>
From ncurses_has_colors:
Checks whether the terminal has color capabilities. This function can be used to write terminal-independent programs.
[emphasis mine]
Use ncurses_attr(NCURSES_A_BOLD); for bold. Note that this function and the related ones are marked as experimental.
From ncurses_attron
Warning This function is EXPERIMENTAL. The behaviour of this function,
its name, and surrounding documentation may change without notice in a
future release of PHP. This function should be used at your own risk.
Warning This function is currently not documented; only its argument
list is available.
[emphasis theirs]
You may find other libraries. You should check to make sure they use terminal-independent techniques. I have found several that use hard-coded sequences instead.
Note that the command-line (shell) equivalent uses tput in order to be terminal independent. I include this information as a starting point for reference. They should be avoided.