【问题标题】:If statements not working correctly on Laravel Blade如果语句在 Laravel Blade 上无法正常工作
【发布时间】:2017-09-21 05:14:23
【问题描述】:

一天前所有项目都运行良好,我无法更改任何系统文件或类似的东西。但是现在刀片 if 语句不起作用。

我的刀片代码是

<html>
<body>
@if($success == "True")
            <script>
                window.parent.successPayment();
            </script>
@else

            <script>
                window.parent.failedPayment("{{$message}}");
            </script>

@endif

渲染后

<html>
<body>
        @if ($success == "True")
            <script>
                window.parent.successPayment();
            </script>
        <?php else: ?>

            <script>
                window.parent.failedPayment("<?php echo e($message); ?>");
            </script>

       <?php endif; ?>


</body>
</html>

If 语句未呈现。我无法解决这个问题。有谁知道我该如何解决这个问题?

解析错误:语法错误,意外的“endif”(T_ENDIF),预期文件结尾(查看:/var/www/vhosts/mysite.site/mysite.site/resources/views/dashboard/test.blade.php )

【问题讨论】:

  • 尝试运行php artisan view:clear
  • 您使用的是什么版本的 PHP,您是否检查了您使用的 Laravel 版本的最低要求。

标签: laravel blade


【解决方案1】:

试试这个

<html>

<body>
    <?php if ($success == "True") {?>
    <script>
        window.parent.successPayment(); 
    </script>

    <?php } else: {?>
    <script>
        window.parent.failedPayment("<?php echo e($message); ?>");   
    </script>

    <?php } endif; ?>

</body>

</html>

【讨论】:

  • 代码正在运行。 setlocale 是个问题。我现在评论这条线和刀片工作
【解决方案2】:

有趣

class DashboardBaseController extends Controller
{

    public function __construct(){
//        setlocale(LC_TIME, "turkish");
//        setlocale(LC_ALL,'turkish');
//
    $this->middleware(function ($request, $next) {
        $user = Auth::user();
        $img = DefaultProfileImage::create($user->name, 256, "#e91e63");
...

如果我评论 setlocale 行代码可以正常工作。

【讨论】:

  • 这可能是一个 laravel 错误。同样的事情发生在我身上。多亏了你,我解决了这个问题。
【解决方案3】:

试试吧。

<html>
<body>
        @if ($success == "True")
            <script>
                window.parent.successPayment();
            </script>
         @else

            <script>
                window.parent.failedPayment("{{ e($message) }}");
            </script>

       @endif

</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-15
    • 1970-01-01
    • 2016-03-05
    • 2012-08-21
    • 2021-05-17
    • 2019-07-23
    • 2015-01-01
    • 2015-09-27
    相关资源
    最近更新 更多