flvll
flvll

Reputation: 53

Mixing PHP and html basic

In a var i want to mix php and html/ inline css, I think i'm almost there with the code below but it keeps failing.

$bgThumb = 'style="background-image:url(' . echo $url . ');"';

Upvotes: 1

Views: 110

Answers (4)

user5299698
user5299698

Reputation:

no need to echo

$bgThumb = 'style="background-image:url(' . $url . ');"';

Upvotes: 0

Jérôme
Jérôme

Reputation: 1080

You can't have an echo in a variable!!!

$bgThumb = 'style="background-image:url(' . $url . ');"';

then

echo $bgThumb;

Upvotes: 0

aksu
aksu

Reputation: 5235

No need for echo to concatenate variables:

$bgThumb = 'style="background-image:url(' . $url . ');"';

echo just displays content in the webpage, it can't be used in the variable.

Upvotes: 1

Stéphane Bruckert
Stéphane Bruckert

Reputation: 22893

$bgThumb = 'style="background-image:url(' . $url . ');"';

Upvotes: 2

Related Questions