snmp_set_valueretrieval
(PHP 4 >= 4.3.3, PHP 5, PHP 7, PHP 8)
snmp_set_valueretrieval — Specify the method how the SNMP values will be returned
Description
snmp_set_valueretrieval(int $method): bool
Parameters
-
method
-
types SNMP_VALUE_LIBRARY The return values will be as returned by the Net-SNMP library. SNMP_VALUE_PLAIN The return values will be the plain value without the SNMP type information. SNMP_VALUE_OBJECT The return values will be objects with the properties value
andtype
, where the latter is one of theSNMP_OCTET_STR
,SNMP_COUNTER
etc. constants. The wayvalue
is returned is based on which one of constantsSNMP_VALUE_LIBRARY
,SNMP_VALUE_PLAIN
is set.
Return Values
Always returns true
.
Examples
Example #1 Using snmp_set_valueretrieval()
<?php snmp_set_valueretrieval(SNMP_VALUE_LIBRARY); $ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1'); // $ret = "STRING: lo" snmp_set_valueretrieval(SNMP_VALUE_PLAIN); $ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1'); // $ret = "lo"; snmp_set_valueretrieval(SNMP_VALUE_OBJECT); $ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1'); // stdClass Object // ( // [type] => 4 <-- SNMP_OCTET_STR, see constants // [value] => lo // ) snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN); $ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1'); // stdClass Object // ( // [type] => 4 <-- SNMP_OCTET_STR, see constants // [value] => lo // ) snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_LIBRARY); $ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1'); // stdClass Object // ( // [type] => 4 <-- SNMP_OCTET_STR, see constants // [value] => STRING: lo // ) ?>
See Also
- snmp_get_valueretrieval() - Return the method how the SNMP values will be returned
- Predefined Constants
© 1997–2021 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/function.snmp-set-valueretrieval.php