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 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏