混合PHP和HTML基本

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 . ');"';
$bgThumb = 'style="background-image:url(' . $url . ');"';

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.

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

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

then

echo $bgThumb;

no need to echo

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