No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

sapi_windows_vt100_support

(PHP 7 >= 7.2.0)

sapi_windows_vt100_supportGet or set VT100 support for the specified stream associated to an output buffer of a Windows console.

Description

sapi_windows_vt100_support ( resource $stream [, bool $enable ] ) : bool

If enable is omitted, the function returns TRUE if the stream stream has VT100 control codes enabled, FALSE otherwise.

If enable is specified, the function will try to enable or disable the VT100 features of the stream stream. If the feature has been successfully enabled (or disabled), the function will return TRUE, or FALSE otherwise.

At startup, PHP tries to enable the VT100 feature of the STDOUT/STDERR streams. By the way, if those streams are redirected to a file, the VT100 features may not be enabled.

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.

Warning

This function uses the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag implemented in the Windows 10 API, so the VT100 feature may not be available on older Windows versions.

PHP: sapi_windows_vt100_support - Manual Home of Manuel PHP  Contents Haut

Parameters

stream

The stream on which the function will operate.

enable

If specified, the VT100 feature will be enabled (if TRUE) or disabled (if FALSE).

PHP: sapi_windows_vt100_support - Manual Home of Manuel PHP  Contents Haut

Return Values

If enable is not specified: returns TRUE if the VT100 feature is enabled, FALSE otherwise.

If enable is specified: Returns TRUE on success or FALSE on failure.

PHP: sapi_windows_vt100_support - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 sapi_windows_vt100_support() default state

By default, STDOUT and STDERR have the VT100 feature enabled.

php -r "var_export(sapi_windows_vt100_support(STDOUT));echo ' ';var_export(sapi_windows_vt100_support(STDERR));"

The above example will output something similar to:

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

The above example will output something similar to:


true false

Example #2 sapi_windows_vt100_support() changing state

You won't be able to enable the VT100 feature of STDOUT or STDERR if the stream is redirected.

php -r "var_export(sapi_windows_vt100_support(STDOUT, true));echo ' ';var_export(sapi_windows_vt100_support(STDERR, true));" 2>NUL

The above example will output something similar to:

true false

Example #3 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');
?>

The above example will output:

Just forgot a letter.
Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-function.sapi-windows-vt100-support.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut