0

I have seen people write @ symbol before a varible in blade templates and even in controller:

@php
    $words = explode(" ", $beneficiary->name);
    $acronym = "";
    $acronym .= @$words[0][0] . @$words[1][0];
@endphp

and then:

<h5 class="card-title mb-1 thumb">{{ $acronym }}</h5>

Can someone explain what is it for?

Prakash Poudel
  • 434
  • 1
  • 5
  • 17
  • 2
    `@` suppresses errors/warnings/notices. In your case, a notice like `NOTICE: Undefined Index 0 in array $words in file x at line y`. – Daniel W. Oct 28 '21 at 16:25
  • 1
    Just to avoid any potential confusion, `@php` and `@endphp` are Laravel specific [Blade directives](https://laravel.com/docs/8.x/blade#blade-directives) and should not be mistaken for PHP's [Error Control Operators](https://www.php.net/manual/en/language.operators.logical.php). – Rwd Oct 28 '21 at 16:36

0 Answers0