phpday 2027 - Call for Papers

snmp_set_string_output_format

(PHP 8 >= 8.6.0)

snmp_set_string_output_format — Set the output format of string values

说明

function snmp_set_string_output_format(Snmp\StringOutput $format): void

Sets the format in which the Net-SNMP library prints the string values returned by the SNMP functions, such as snmp2_get() or snmp2_real_walk(). The format only applies to string values whose MIB object has no DISPLAY-HINT.

A new SNMP object takes its initial string output format from the value set with this function. To change it for a single session, use SNMP::setStringOutputFormat() instead.

参数

format

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

返回值

没有返回值。

示例

示例 #1 Printing a binary string as text

<?php

echo snmp2_get('localhost', 'public', 'SNMP-FRAMEWORK-MIB::snmpEngineID.0'), PHP_EOL;

snmp_set_string_output_format(Snmp\StringOutput::Ascii);
echo snmp2_get('localhost', 'public', 'SNMP-FRAMEWORK-MIB::snmpEngineID.0'), PHP_EOL;

?>

以上示例的输出类似于:

Hex-STRING: 80 00 1F 88 80 1C FC 9A 1B 26 7B FF 6A 00 00 00
00
STRING: ".........&{.j...."

参见

+添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top