snmp_set_valueretrieval Specify the method how the SNMP values will be returned php函数分享


snmp_set_valueretrieval

(PHP 4 >= 4.3.3, PHP 5)

snmp_set_valueretrieval Specify the method how the SNMP values will be returned

说明

bool snmp_set_valueretrieval ( int $method = SNMP_VALUE_LIBRARY )

参数

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 hint.
SNMP_VALUE_OBJECT The return values will be objects with the properties "value" and "type", where the latter is one of the SNMP_OCTET_STR, SNMP_COUNTER etc. constants. The way "value" is returned is based on which one of constants SNMP_VALUE_LIBRARY, SNMP_VALUE_PLAIN is set.

范例

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
 // )

 // PHP 5.4+ examples
 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
 // )

?>

更新日志

版本 说明
5.4.0

Constants SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY may be combined with SNMP_VALUE_OBJECT resulting different way of representing contents of value array element in return value of GET-function. If no SNMP_VALUE_{PLAIN,LIBRARY} constant is accompanying SNMP_VALUE_OBJECT, SNMP_VALUE_LIBRARY is used.

Prior to 5.4.0 SNMP_VALUE_OBJECT effecively meant SNMP_VALUE_OBJECT|SNMP_VALUE_PLAIN.

参见

  • snmp_get_valueretrieval() – Return the method how the SNMP values will be returned
  • 预定义常量

—-想了解更多的linux相关异常处理怎么解决关注<计算机技术网(www.ctvol.com)!!>



本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/htmltutorial/77357.html

(0)
上一篇 2020年4月22日
下一篇 2020年4月22日

精彩推荐