phpday 2027 - Call for Papers

SNMP::setStringOutputFormat

(PHP 8 >= 8.6.0)

SNMP::setStringOutputFormat — Set the output format of string values of the session

Описание

public function SNMP::setStringOutputFormat(Snmp\StringOutput $format): bool

Sets the format in which the string values returned by the requests of this session are printed. The format only applies to string values whose MIB object has no DISPLAY-HINT.

It does not change the format used by the other sessions, nor by functions such as snmp2_get(); use snmp_set_string_output_format() for those.

Список параметров

format

The format to use. See Snmp\StringOutput for the available formats.

Возвращаемые значения

Функция возвращает логическое значение true.

Примеры

Пример #1 Printing a binary string as text

<?php

$session = new SNMP(SNMP::VERSION_2c, 'localhost', 'public');
$session->setStringOutputFormat(Snmp\StringOutput::Ascii);

echo $session->get('SNMP-FRAMEWORK-MIB::snmpEngineID.0'), PHP_EOL;

?>

Вывод приведённого примера будет похож на:

STRING: ".........&{.j...."

Смотрите также

+Добавить

Примечания пользователей

Пользователи ещё не добавляли примечания для страницы
To Top