I am writing php-console app with readline use for user input commands.
This is how I am using it:
$input = readline("\033$label\033\n");
And it looks like this in cmd terminal:
But with this same terminal in vscode this questions marks are not visible. When I remove color codes ("\033", "\033") they dissapears.
I tested this app in cygwin terminal too and questions marks are not visible, but in this places are two space symbols.
Please for help.
You need to output correct control codes in accordance with the terminal emulator being used. What works in an xterm emulator may not in vt100 or whatever Windows uses.
stream_isatty(STDOUT)
to detect if the output is a terminal.PHP_OS_FAMILY
or PHP_OS
to detect the OS you're currently running on.$_ENV['TERM']
to determine which terminal emulator is in use.Based on these three pieces of information you can determine whether or not to use "fancy" output formatting, and output the control codes appropriate to a given terminal emulator.