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

# sapi_windows_vt100_support

(PHP 7 >= 7.2.0)

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

### 説明

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

If `enable` is omitted, the function return `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.

警告

The 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.

### パラメータ

`stream`

  The stream on which the function will operate.

`enable`

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

### 返り値

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

If `enable` is specified: 成功した場合に `TRUE` を、失敗した場合に `FALSE` を返します。

### 例

例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));"

上の例の出力は、 たとえば以下のようになります。

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

例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

上の例の出力は、 たとえば以下のようになります。

true false