Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Laraveldeep's avatar

Regular PHP Tag In Blade?

Hi,

Inside blade @foreach loop, I need to do a small computation (with new variables). what is the best way to do it?

Should I use regular php tag like this?


@if(some condition)
<?php
    $var1 = 1;
    $var2 = 2;
   // do some computation
?>

<div>display value based on outcome</div>
@endif
0 likes
3 replies

Please or to participate in this conversation.