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

joelmez4's avatar

How to pass a PHP variable into a Laravel helper

Hi guys, I know that this is basic question but I really want to know how to pass a PHP variable into helper {{ url() }}

<?php
    
    $tag= 'electronics';    

?>

<a href="{{ url('/products')  }}">Products</a>

Thanks in advance.

0 likes
1 reply
Abi's avatar

try

{{ url('/products',[$tag]) }}

Please or to participate in this conversation.