Raw PHP in Laravel blade view

In some situations, it's useful to embed PHP code into your Laravel views. You can use the Blade @php directive to execute a block of plain PHP within your template:

@php // Raw PHP code here @endphp

Only use this as a last resort, as this logic should probably be in a Controller.


Explore our projects