sapi_windows_vt100_support Get or set VT100 support for the specified stream associated to an output buffer of a Windows console.
发表日期:2021-07-01 10:15:43 | 来源: | | 浏览(724) 分类:杂项 函数
sapi_windows_vt100_support
(PHP 7 >= 7.2.0, PHP 8)
sapi_windows_vt100_support — Get or set VT100 support for the specified stream associated to an output buffer of a Windows console.
说明
$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.
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.
参数
-
stream
-
The stream on which the function will operate.
-
enable
-
If specified, the VT100 feature will be enabled (if
true
) or disabled (iffalse
).
返回值
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
示例 #3 Example usage of VT100 support enabled
1 | <?php |
2 | $out = fopen ( 'php://stdout' , 'w' ); |
3 | fwrite( $out , 'Just forgot a lettr.' ); |
4 | // Moves the cursor two characters backwardsfwrite($out, "\033[2D"); |
5 | // Inserts one blank, shifting existing text to the right -> Just forgot a lett r.fwrite($out, "\033[1@"); |
6 | fwrite( $out , 'e' ); |
7 | ?> |
以上例程会输出:
Just forgot a letter.
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- connection_aborted 检查客户端是否已经断开(0)
- connection_status 返回连接的状态位(0)
- constant 返回一个常量的值(0)
- define 定义一个常量(0)
- defined 检查某个名称的常量是否存在(0)
- die 等同于 exit()(0)
- eval 把字符串作为PHP代码执行(0)
- exit 输出一个消息并且退出当前脚本(0)
- get_browser 获取浏览器具有的功能(0)
- __halt_compiler 中断编译器的执行(0)
- highlight_file 语法高亮一个文件(0)
- highlight_string 字符串的语法高亮(0)
- hrtime 获取系统的高精度时间(0)
- ignore_user_abort 设置客户端断开连接时是否中断脚本的执行(0)
- pack 将数据打包成二进制字符串(0)
- php_strip_whitespace 返回删除注释和空格后的PHP源码(0)
- sapi_windows_cp_conv Convert string from one codepage to another(0)
- sapi_windows_cp_get Get current codepage(0)
- sapi_windows_cp_is_utf8 Indicates whether the codepage is UTF-8 compatible(0)
- sapi_windows_cp_set Set process codepage(0)
- sapi_windows_generate_ctrl_event Send a CTRL event to another process(0)
- sapi_windows_set_ctrl_handler Set or remove a CTRL event handler(0)
- sapi_windows_vt100_support Get or set VT100 support for the specified stream associated to an output buffer of a Windows console.(0)
- show_source 别名 highlight_file()(0)
- sleep 延缓执行(0)
- sys_getloadavg 获取系统的负载(load average)(0)
- time_nanosleep 延缓执行若干秒和纳秒(0)
- time_sleep_until 使脚本睡眠到指定的时间为止。(0)
- uniqid 生成一个唯一ID(0)
- unpack Unpack data from binary string(0)
- usleep 以指定的微秒数延迟执行(0)
- 字符串 函数(101)