snmp_set_string_output_format

Set the output format of string values

Description

void snmp_set_string_output_format(Snmp\StringOutput $format)

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.

Parameters

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

Return Values

No value is returned.

Examples

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

?>

The above example will output something similar to:

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

See Also

  • Snmp\StringOutput
  • SNMP::setStringOutputFormat
  • snmp_set_output_option