What is the point of writing @php @endphp instead of <?php ?> in Laravel Blade?

Viewed 10219

You can write PHP code like below in Laravel.

@php
    //
@endphp

Alternately you can write,

<?php
//
?>

What is the difference between about two method? What are the advantages?

For a example when we use to display something, we can use {{ $name}}. It can save developer time because if we use PHP we have to write <?php echo $name; ?>.

But what is the point of writing @php @endphp instead of <?php ?>

1 Answers
Related