Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Laravel 6应用程序中的非数值错误_Javascript_Php_Html_Laravel_Laravel 6 - Fatal编程技术网

Javascript Laravel 6应用程序中的非数值错误

Javascript Laravel 6应用程序中的非数值错误,javascript,php,html,laravel,laravel-6,Javascript,Php,Html,Laravel,Laravel 6,非数值问题 这是我的php代码 <ul class="product_marks"> @if($row->discount_price == NULL) <li class="product_mark product_discount" style="background: green;">NEW</li> @else @php $amount=$row->selli

非数值问题

这是我的php代码

<ul class="product_marks">
    @if($row->discount_price == NULL)
        <li class="product_mark product_discount"
        style="background: green;">NEW</li>

    @else
        @php
        $amount=$row->selling_price - $row->discount_price;
        $discount=$amount/$row->selling_price * 100;
        @endphp
        <li class="product_mark product_discount">

        {{intval($discount)}}%
        </li>
    @endif
</ul>
    @如果($row->折扣\价格==NULL)
  • 新建
  • @否则 @php $amount=$row->售价-$row->折扣价; $折扣=$amount/$row->售价*100; @endphp
  • {{intval($折扣)}}}%
  • @恩迪夫
错误:


“我的视图”文件中遇到非数值


有什么问题。

检查并键入所有这些变量:

$amount=$row->selling_price - $row->discount_price;
$discount=$amount/$row->selling_price * 100;

它可以是字符串或
null

首先检查这些属性的类型:

$row->discount_price
$row->selling_price
然后您可以再次检查最终结果,如下所示:

{{is_numeric($discount) ? $discount : ''}}

你能显示错误吗?遇到了一个非数值..这是我的错误视图文件。。