大网数据广告活动
PHP 语言与运行手册

ssh2_shell_resize · Change the dimensions of a channel's pseudo-terminal

· 52CE 我爱测

ssh2_shell_resize — Change the dimensions of a channel's pseudo-terminal

ssh2_shell_resize

(PECL ssh2 >= 1.4)

ssh2_shell_resize — Change the dimensions of a channel's pseudo-terminal

Description

function ssh2_shell_resize(
    resource $channel,
    int $width,
    int $height,
    int $width_px = 0,
    int $height_px = 0
): bool

Requests that the pseudo-terminal (PTY) attached to the given channel be resized to the given dimensions.

Note:

The extension declares only the first three parameters, under the name session for channel. As a result, width_px and height_px can only be passed positionally.

Parameters

channel

An SSH channel stream, as returned by ssh2_exec() or ssh2_shell().

width

The width of the terminal, in characters.

height

The height of the terminal, in characters.

width_px

The width of the terminal in pixels, or 0 to leave the pixel dimensions unspecified.

height_px

The height of the terminal in pixels, or 0 to leave the pixel dimensions unspecified.

Return Values

Returns true, or false when channel is not an SSH channel stream.

The outcome of the resize request itself is not reported: true is returned even when the remote end does not honour it.

Errors/Exceptions

An E_WARNING is emitted when channel is not an SSH channel stream.

Examples

Example #1 Resizing the pseudo-terminal of a shell

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$shell = ssh2_shell($connection, 'xterm', null, 80, 24);

// Tell the remote end the terminal is now 132 columns by 43 rows
ssh2_shell_resize($shell, 132, 43);
?>

See Also

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。