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

Beschreibung

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.

Parameter-Liste

format

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

Rückgabewerte

Es wird kein Wert zurückgegeben.

Beispiele

Beispiel #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;

?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

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

Siehe auch

+add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top