I am using Laravel blade. i want to concatenate a php variable with string inside blade code.
for Example in js:
<img class="img-responsive" src='http://example.com/'+ user_id +'/picture?type=square';/>
how to write this with php variable?
<img class="img-responsive" src='http://example.com/'. {{ $user_id}} .'/picture?type=square';/>
You can do this:
<img src="http://example.com/{{ $user_id }}/picture?type=square">
Or:
<img src="{{ 'http://example.com/' . $user_id . '/picture?type=square'}}">
But it's always a good idea to use asset()
helper for this:
<img src="{{ asset($userId . '/picture?type=square') }}">
You need to write it like this:
<img class="img-responsive" src='http://example.com/{{ $user_id }}/picture?type=square';/>
You don't need to concatenate using .
in Blade
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With