简体   繁体   English

奇怪的PHP错误

[英]strange php error

I have the following code: 我有以下代码:

    var_dump($cumulitive);
    $y_axis_max = max($cumulitive)*1.3;
    var_dump($y_axis_max);

It outputs the following: 它输出以下内容:

array(16) {
  [0]=>
  int(0)
  [1]=>
  int(0)
  [2]=>
  int(0)
  [3]=>
  int(0)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [6]=>
  int(0)
  [7]=>
  int(0)
  [8]=>
  int(0)
  [9]=>
  int(0)
  [10]=>
  int(0)
  [11]=>
  int(4)
  [12]=>
  int(4)
  [13]=>
  int(4)
  [14]=>
  int(9)
  [15]=>
  int(9)
}
float(NAN)

As you can see, $y_axis_max is giving NAN. 如您所见,$ y_axis_max为NAN。 So I try this: I restart WampServer. 因此,我尝试这样做:我重新启动WampServer。 It works now. 现在可以使用了。 I refresh the browser. 我刷新浏览器。 Works again. 再次工作。 refresh the browser again. 再次刷新浏览器。 Now it doesn't work, and I can't get it to work again without restarting Apache. 现在它不起作用了,而且如果不重新启动Apache,我将无法使其再次起作用。 From the 3rd request on it stops working. 从第三个请求开始,它停止工作。

It USED to work just fine. 它可以正常工作。 Then I changed some things. 然后我改变了一些东西。 Specifically, I modified my app to use the DateTime class in a few places. 具体来说,我修改了我的应用程序以在某些地方使用DateTime类。 But that shouldn't make this strange error occur. 但这不应使此奇怪的错误发生。 Any ideas on how to debug this? 关于如何调试的任何想法?

If I call the $y_axis_max = .. line of code twice in a row, then I get this for $y_axis_max: 如果我连续两次调用$ y_axis_max = ..代码行,那么我会以$ y_axis_max的形式获得此代码:

float(@.7)

What the heck is that? 那是什么呀?

EDIT: Seems that calling DateTime::diff earlier causes the error. 编辑:似乎早期调用DateTime :: diff会导致错误。 Any workaround ideas? 有任何解决方法吗?

max() will work on arrays. max()将在数组上工作。 Looks like you have some form of corruption in your code. 看起来您的代码中存在某种形式的损坏。 If one of the elements in the array is a NAN you will get this result. 如果数组中的元素之一是NAN,则将得到此结果。 Try testing a smaller script on your server in order to isolate the problem. 尝试在服务器上测试较小的脚本,以便找出问题所在。

Seems that calling DateTime::diff earlier causes the error. 似乎更早调用DateTime :: diff会导致错误。 I just used a work-around so not to use it. 我只是使用了一种变通方法,所以不再使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM