1

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 . ');"';
2
  • echo performs output immediately. it is NOT a function and has no return value, so you cannot assign echoed data to a variable. Commented Jan 29, 2014 at 17:11
  • You can mark the question as solved. Commented Jan 29, 2014 at 18:33

4 Answers 4

2
$bgThumb = 'style="background-image:url(' . $url . ');"';
Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

connect = 'concatenate'
0

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

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

then

echo $bgThumb;

Comments

0

no need to echo

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.