doumeinuoye81969 2017-02-14 08:05
浏览 22
已采纳

遇到一个非常好的数值 - 这是什么意思?

I have the following message flagging up when notices are turned on:

Notice: A non well formed numeric value encountered

Does this mean the value expected was not a simple integer? The line referenced is showing this:

$per = ($raw>0?ceil((($raw/$cast)/5)*100):0).'%';

  • 写回答

3条回答 默认 最新

  • dqxsuig64994 2017-04-06 14:45
    关注

    Thanks very much for your comments, but after looking at this with fresh eyes, I was able to look abit further into the code, and it dawned on me what was happening.

    As asked above, I dumped the values of $raw and $cast, which were returned as:

    string(2) "14" string(7) "3 votes"
    

    So clearly, the '3 votes' is supposed to be a number, or the calculation isn't going to work. I had a look at the line above, which read:

    $cast = (get_post_meta($id, '_kksr_casts', true)?get_post_meta($id, '_kksr_casts', true):'0').' votes';
    

    Bingo. I removed the ending 'votes' output, leaving just the number. And the message disappears. I still want the original text to be outputted though, so I found the next line after 606 contained this:

    $row = $avg . ' (' . $per . ') ' . $cast;
    

    So I just added 'votes' on the end of this line, which results in the correct output in the WP Admin, and the error now gone.

    Seems fixed, and a pull request created. Thanks for all your help guys.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入