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

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了