首页 > 解决方案 > 分页中遇到刀片 php 的格式不正确的数值

问题描述

我正在尝试在 php 分页中显示页面中显示的项目数。这是我的代码:

@if ($result->onFirstPage())
     {{1 . '~' . $result->count()}}
@else
    {{(($result->currentPage()-1)*12)+1 . '~' . + (($result->currentPage()-1)*12) + $result->count() }}
@endif

我已经尝试将它们类型转换为 int 但仍然无法正常工作。此计算(($result->currentPage()-1)*12)效果很好,但如果我添加$result->count()它会返回non well formed numeric value错误。我怎么可能修复这个?关于如何解决这个问题的一些建议不起作用。

标签: phppagination

解决方案


好,知道了。我只是将它们括在一个括号中!

((($result->currentPage()-1)*12) + $result->count())

所以我的行将如下所示:

{{(($result->currentPage()-1)*12)+1 . '~' . + ((($result->currentPage()-1)*12) + $result->count()) }}

推荐阅读