sapi_windows_vt100_support
sapi_windows_vt100_support
Get or set VT100 support for the specified stream associated to an output buffer of a Windows console.
bool **sapi_windows_vt100_support** resource $stream $enable
If is null, the function returns true if the stream has VT100 control codes enabled, false otherwise.
enable``stream
If is a , the function will try to enable or disable the VT100 features of the stream .
If the feature has been successfully enabled (or disabled), the function will return true, or false otherwise.
enable``bool``stream
At startup, PHP tries to enable the VT100 feature of the / streams. By the way, if those streams are redirected to a file, the VT100 features may not be enabled.
STDOUT``STDERR
If VT100 support is enabled, it is possible to use control sequences as they are known from the VT100 terminal. They allow the modification of the terminal's output. On Windows these sequences are called Console Virtual Terminal Sequences.
Waarschuwing: > This function uses the flag implemented in the Windows 10 API, so the VT100 feature may not be available on older Windows versions.
ENABLE_VIRTUAL_TERMINAL_PROCESSING
streamThe stream on which the function will operate.
enable
If , the VT100 feature will be enabled (if true) or disabled (if false).
bool
If is null: returns true if the VT100 feature is enabled, false otherwise.
enable
If is a : return.success
enable``bool
Voorbeeld: default state
By default, and have the VT100 feature enabled.
STDOUT``STDERR
php -r "var_export(sapi_windows_vt100_support(STDOUT));echo ' ';var_export(sapi_windows_vt100_support(STDERR));"
true true
By the way, if a stream is redirected, the VT100 feature will not be enabled:
php -r "var_export(sapi_windows_vt100_support(STDOUT));echo ' ';var_export(sapi_windows_vt100_support(STDERR));" 2>NUL
true false
Voorbeeld: changing state
You won't be able to enable the VT100 feature of or if the stream is redirected.
STDOUT``STDERR
php -r "var_export(sapi_windows_vt100_support(STDOUT, true));echo ' ';var_export(sapi_windows_vt100_support(STDERR, true));" 2>NUL
true false
Voorbeeld: Example usage of VT100 support enabled
<?php
$out = fopen('php://stdout','w');
fwrite($out, 'Just forgot a lettr.');
// Moves the cursor two characters backwards
fwrite($out, "\033[2D");
// Inserts one blank, shifting existing text to the right -> Just forgot a lett r.
fwrite($out, "\033[1@");
fwrite($out, 'e');
?>
Just forgot a letter.