admin管理员组文章数量:1333710
Warning: A non-numeric value encountered in line 107.
<div class="like">
<?php
$nonce = wp_create_nonce("my_user_vote_nonce");
$likeLink = admin_url('admin-ajax.php?action=my_user_vote&custom=like&post_id='.$post->ID.'&nonce='.$nonce);
?>
<a class="like" data-image="<?php bloginfo('template_url');?>/images/loading.gif" data-field="like" data-nonce="<?php echo $nonce ?>" data-post_id="<?php echo $post->ID ?>" href="<?php echo $link ?>" title="Like"><span><?php echo number_format(get_post_meta($post->ID, "like", true) * 1, 0, ',', '.'); ?></span></a>
</div>
line 107
<a class="like" data-image="<?php bloginfo('template_url');?>/images/loading.gif" data-field="like" data-nonce="<?php echo $nonce ?>" data-post_id="<?php echo $post->ID ?>" href="<?php echo $link ?>" title="Like"><span><?php echo number_format(get_post_meta($post->ID, "like", true) * 1, 0, ',', '.'); ?></span></a>
Warning: A non-numeric value encountered in line 107.
<div class="like">
<?php
$nonce = wp_create_nonce("my_user_vote_nonce");
$likeLink = admin_url('admin-ajax.php?action=my_user_vote&custom=like&post_id='.$post->ID.'&nonce='.$nonce);
?>
<a class="like" data-image="<?php bloginfo('template_url');?>/images/loading.gif" data-field="like" data-nonce="<?php echo $nonce ?>" data-post_id="<?php echo $post->ID ?>" href="<?php echo $link ?>" title="Like"><span><?php echo number_format(get_post_meta($post->ID, "like", true) * 1, 0, ',', '.'); ?></span></a>
</div>
line 107
<a class="like" data-image="<?php bloginfo('template_url');?>/images/loading.gif" data-field="like" data-nonce="<?php echo $nonce ?>" data-post_id="<?php echo $post->ID ?>" href="<?php echo $link ?>" title="Like"><span><?php echo number_format(get_post_meta($post->ID, "like", true) * 1, 0, ',', '.'); ?></span></a>
Share
Improve this question
edited Mar 13, 2020 at 12:12
Ersin
asked Mar 13, 2020 at 11:45
ErsinErsin
31 silver badge3 bronze badges
2
- You have a lot of stuff on that line, can you split it into multiple lines so that we can figure out which part is the problem? I have a suspicion where it is. Otherwise, are you asking where the warning is, what the warning means, or are you asking how to fix it? – Tom J Nowell ♦ Commented Mar 13, 2020 at 12:06
- Thank you Tom for your help, i want to fix it. Why it is happening with PHP 7.1. – Ersin Commented Mar 13, 2020 at 12:13
1 Answer
Reset to default 1I suspect the problem is this:
echo number_format(get_post_meta($post->ID, "like", true) * 1, 0, ',', '.')
Here, we take the post meta named like
and multiply it by 1, but what if that post meta doesn't contain a number? What if it contains something else?
For example, if we did
本文标签:
functionsPHP 71Warning A nonnumeric value encountered in
版权声明:本文标题:functions - PHP 7.1 | Warning: A non-numeric value encountered in 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1742355763a2459378.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
2 x 4
, we would expect PHP to give us 8, which is correct, but what if we tell PHP to multiple 2 x "hello"
? or
发表评论