AnswerBun.com

unwanted '/' at the end of two concatenated strings used in tag

Stack Overflow Asked by dani on October 16, 2020

I have a simple laravel project.I want to concatenate two string.

$base_url ="https://image_base_url/";
$image_path = "/image_name.jpg";
$full_url=$base_url.$image_path;

then I use full_url inside img tag like so in laravel in index.blade.php file

<img src={{$full_url}} />;

the full_url is correct but when it place in src it will get an ‘/’ at
the end of it and image can not find that url

src will be like below
src ="http://baseurl/imagepath.jpg/"

but I want it like this

src="http://baseurl/imagepath.jpg"

any of you my friends can help me out?thank you

2 Answers

do like this

<img src="{{$full_url}}" />;

Correct answer by 夜神夜神 on October 16, 2020

You have to write php variable in double quotes.

<img src="{{$full_url}}" alt="tag" />;

It's good practice to add alt="" attribute in img tag

Answered by Bhargav Variya on October 16, 2020

Add your own answers!

Related Questions

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir