Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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
PHP-7.4 Laravel“下一个错误异常:遇到格式不正确的数值”_Php_Laravel_Http Status Code 500 - Fatal编程技术网

PHP-7.4 Laravel“下一个错误异常:遇到格式不正确的数值”

PHP-7.4 Laravel“下一个错误异常:遇到格式不正确的数值”,php,laravel,http-status-code-500,Php,Laravel,Http Status Code 500,当我试图打开站点时,出现HTTP 500错误,并且Laravel日志显示:遇到了格式不正确的数值 PHP版本:7.4 在铸造intval$sec/60%60之前,这里的值为$sec。 值为60.316000,此值的类型为:字符串 以下是index.blade.php文件的内容: 以下是helpers.php文件的内容: 在index.blade.php文件中,函数名为strings 29,50,86122150,代码如下所示: @if($recomment != NULL)

当我试图打开站点时,出现HTTP 500错误,并且Laravel日志显示:遇到了格式不正确的数值

PHP版本:7.4

在铸造intval$sec/60%60之前,这里的值为$sec。 值为60.316000,此值的类型为:字符串

以下是index.blade.php文件的内容:

以下是helpers.php文件的内容:

在index.blade.php文件中,函数名为strings 29,50,86122150,代码如下所示:

@if($recomment != NULL)
            @foreach($recomment as $result)
                <?php $video_categories = get_video_form_cat($result->ID) ?>
                @if(count($video_categories)>0)
                    <h2>Recommended Category For You <a style="text-decoration: none" href="{{URL('categories/')}}/{{$result->ID}}.{{$result->post_name}}.html"><span>-{{$result->title_name}}</span></a></h2>
                    <div class="row content-image">
                         @foreach($video_categories as $result)
                            <?php $rating=GetRatingVideo($result->string_Id);?>
                            <div class="col-xs-6 col-sm-4 col-md-3  image-left">
                                <div class="col">
                                    <div class="col_img">
                                        <span class="hd">HD</span>
                                        <a href="{{URL('watch')}}/{{$result->string_Id.'/'.$result->post_name}}.html">
                                            <img src="{{$result->getImageUrl($result->poster)}}" alt="{{$result->title_name}}" height="177" />
                                        </a>
                                        <div class="position_text">
                                            <p class="icon-like"></p>
                                            <p class="percent">{{floor($rating['percent_like'])}}%</p>
                                            <p class="time_minimute">{{sec2hms($result->duration)}}</p>
                                        </div>
                                    </div>
                                    <h3><a href="{{URL('watch')}}/{{$result->string_Id.'/'.$result->post_name}}.html">{{str_limit($result->title_name,30)}}</a></h3>
                                </div>
                            </div>
                        @endforeach
                    </div>
                @endif
            @endforeach
        @endif
以下是来自Laravel日志的完整错误消息:

Next ErrorException: A non well formed numeric value encountered (View: /var/www/clients/client0/web3/web/resources/views/home/index.blade.php) in /var/www/clients/client0/web3/web/app/Helper/helpers.php:35
Stack trace:
#0 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(44): Illuminate\View\Engines\CompilerEngine->handleViewException()
#1 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(58): Illuminate\View\Engines\PhpEngine->evaluatePath()
#2 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/View/View.php(135): Illuminate\View\Engines\CompilerEngine->get()
#3 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/View/View.php(106): Illuminate\View\View->getContents()
#4 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/View/View.php(80): Illuminate\View\View->renderContents()
#5 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Http/Response.php(51): Illuminate\View\View->render()
#6 /var/www/clients/client0/web3/web/vendor/symfony/http-foundation/Response.php(198): Illuminate\Http\Response->setContent()
#7 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1229): Symfony\Component\HttpFoundation\Response->__construct()
#8 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(112): Illuminate\Routing\Router->prepareResponse()
#9 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}()
#10 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#11 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#12 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#13 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(114): Illuminate\Pipeline\Pipeline->then()
#14 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(68): Illuminate\Routing\ControllerDispatcher->callWithinStack()
#15 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch()
#16 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/Route.php(134): Illuminate\Routing\Route->runWithCustomDispatcher()
#17 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\Routing\Route->run()
#18 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#19 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#20 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#21 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#22 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(710): Illuminate\Pipeline\Pipeline->then()
#23 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(674): Illuminate\Routing\Router->runRouteWithinStack()
#24 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->dispatchToRoute()
#25 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(236): Illuminate\Routing\Router->dispatch()
#26 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#27 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#28 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#29 /var/www/clients/client0/web3/web/app/Http/Middleware/VerifyCsrfToken.php(31): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
#30 [internal function]: App\Http\Middleware\VerifyCsrfToken->handle()
#31 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#32 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#33 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#34 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#35 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#36 [internal function]: Illuminate\Session\Middleware\StartSession->handle()
#37 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#38 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#39 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#40 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#41 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#42 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle()
#43 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#44 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#45 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#46 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#47 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#48 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#49 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\Pipeline\Pipeline->then()
#50 /var/www/clients/client0/web3/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#51 /var/www/clients/client0/web3/web/index.php(96): Illuminate\Foundation\Http\Kernel->handle()
#52 {main}

该错误特别是调出helpers.php的第35行:

   function sec2hms ($sec, $padHours = false)
         {
            $hms = "";
            $hours = intval(intval($sec) / 3600);
            if($hours > 0){
              $hms .= ($padHours)? str_pad($hours, 2, "0", STR_PAD_LEFT). ':': $hours. ':';  
            }
            $minutes = intval(($sec / 60) % 60);
            $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
            $seconds = intval($sec % 60);
            $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
            return $hms;
        }
$minutes = intval(($sec / 60) % 60);
对我来说最突出的是,这个值被转换成一个整数,但是这是在计算完成之后。如果您试图对不同的值类型执行计算,则会遇到问题

例如,请注意,它没有标记第31行:

$hours = intval(intval($sec) / 3600);
不同之处在于$sec首先被转换为整数

我会将转换移到函数的顶部,这样依赖于变量的任何计算都可以确保它是整数

$sec = intval($sec);

...

$hours = intval($sec / 3600);

...

$minutes = intval(($sec / 60) % 60);

有许多其他方法可以清理函数,但这应该解决最紧迫的问题。

这是否回答了您的问题@纳桑达森号