dongwei4652 2017-09-26 17:10
浏览 74
已采纳

测试RRD支持时PHP未捕获错误

I have this PHP file which Im using to test RRD support:

<?php
$result=rrd_fetch( "/ang.rrd", array( "AVERAGE", "--resolution", "60", "--start", "-1d", "--end", "start+1h" ) );

foreach ( $result["data"]["myfield"] as $key => $value )
{
    echo "At timestamp $key, the value for myfield is $value.
";
}
?>

If I browse to the file I get the following:

PHP Fatal error:  Uncaught Error: Call to undefined function rrd_fetch() in /var/www/html/graph.php:2
Stack trace:
#0 {main}
  thrown in /var/www/html/graph.php on line 2

and if I try to run the file on the command line I get the following:

PHP Notice:  Undefined index: myfield in /var/www/html/graph.php on line 4
PHP Warning:  Invalid argument supplied for foreach() in /var/www/html/graph.php on line 4

Im not sure why. Could somebody shed some light on why this is happening please?

  • 写回答

1条回答 默认 最新

  • duanhu7400 2017-09-26 17:15
    关注

    The answer lies in your error message:

    Call to undefined function rrd_fetch

    The issue is that the rrd functions are not provided by default. They have to be added by install the rrd pecl package.

    Try installing rrd and retrying your code: https://pecl.php.net/package/rrd

    rrd documentation: http://www.php.net/rrd

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题