Php Laravel7在刀片文件中使用函数

Php Laravel7在刀片文件中使用函数,php,function,curl,laravel-7,Php,Function,Curl,Laravel 7,我使用的是Laravel7,有一个视图文件,我在视图文件的顶部放了一个函数。 然而,我现在在页面上得到一个错误。我基本上只是尝试创建一个页面,查询URL数据库,然后使用curl函数查看网站是否可用 syntax error, unexpected 'endforeach' (T_ENDFOREACH) (View: /Applications/MAMP/htdocs/local-devcenter/resources/views/uptime-dashboard.blade.php) 这是我

我使用的是Laravel7,有一个视图文件,我在视图文件的顶部放了一个函数。 然而,我现在在页面上得到一个错误。我基本上只是尝试创建一个页面,查询URL数据库,然后使用curl函数查看网站是否可用

syntax error, unexpected 'endforeach' (T_ENDFOREACH) 
(View: /Applications/MAMP/htdocs/local-devcenter/resources/views/uptime-dashboard.blade.php)
这是我的刀片文件代码

<?php
//stuck function here becauae needed it only in this template
function uptime_monitor($url) 
{
    $timeout = 10;
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout);
    $http_respond = curl_exec($ch);
    $http_respond = trim(strip_tags($http_respond));
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if (($http_code == "200") || ($http_code == "302")) {
        return true;
    } else {
        // return $http_code;, possible too
        return false;
    }
      curl_close($ch);
}

?>
<table class="table-auto rounded text-center" id="sitegridtable">
                                <thead>
                                  <!--<tr>
                                    <th class="border w-1/4 px-4 py-2">Site URL</th>
                                    <th class="border w-1/6 px-4 py-2">HTTPS</th>
                                    <th class="border w-1/6 px-4 py-2">HTTP</th>
                                    <th class="border w-1/6 px-4 py-2">Last updated On</th>
                                    <th class="border w-1/6 px-4 py-2">Actions</th>
                                  </tr>-->
                                </thead>
                                <tbody>
                                    @foreach($clientdomains as $clientdomain)
                                        <tr>
                                            <td> {{$clientdomain->websiteurl}}</td>
                                            @if(@uptime_monitor('http://'.$clientdomain->websiteurl))

                                               <td>Up</td> 
                                           
                                            @else 
                                              <td>Down</td>
                                            
                                            <td></td>
                                            <td> </td>
                                            <td> 
                                                
                                            </td>
                                        </tr>
                                    @endforeach
                                </tbody>
 </table>

@foreach($clientdomains作为$clientdomain)
{{$clientdomain->websiteurl}
@if(@uptime_monitor('http://'.$clientdomain->websiteurl))
向上的
@否则
向下
@endforeach

@foreach($clientdomains作为$clientdomain)
{{$clientdomain->websiteurl}
@if(@uptime_monitor('http://'.$clientdomain->websiteurl))
向上的
@否则
向下
@恩迪夫
@endforeach

你错过了
@endif
谢谢,我错过了。
<table class="table-auto rounded text-center" id="sitegridtable">
                                <thead>
                                  <!--<tr>
                                    <th class="border w-1/4 px-4 py-2">Site URL</th>
                                    <th class="border w-1/6 px-4 py-2">HTTPS</th>
                                    <th class="border w-1/6 px-4 py-2">HTTP</th>
                                    <th class="border w-1/6 px-4 py-2">Last updated On</th>
                                    <th class="border w-1/6 px-4 py-2">Actions</th>
                                  </tr>-->
                                </thead>
                                <tbody>
                                    @foreach($clientdomains as $clientdomain)
                                        <tr>
                                            <td> {{$clientdomain->websiteurl}}</td>
                                            @if(@uptime_monitor('http://'.$clientdomain->websiteurl))

                                               <td>Up</td> 
                                           
                                            @else 
                                              <td>Down</td>
                                            @endif
                                            <td></td>
                                            <td> </td>
                                            <td> 
                                                
                                            </td>
                                        </tr>
                                    @endforeach
                                </tbody>
 </table>