-3

I have searched the site for an answer to my question, however the solutions have been unable to solve my problem.

My Problem is: I have tried to add a php echo element inside of an html tag. However it is throwing off an error as seen in the screenshot. I have tried various ways to adjust this code unsuccessfully.

I should mention that it is a simple MVC application.

screenshot

Thanks in advance for any advice.

3 Answers3

1

You were concating wrong. Be careful with ' and ".

echo '<img src= " '. $page->image . ' " <br>';

The spaces between " are here just for readability.

And btw you can't execute PHP code inside html.

The Truth
  • 63
  • 10
1

You can't separate your string like that:

echo 'Image' 'img src='...;
            ^

If you want to concatenate everything, use . or just put it all on the same string:

echo 'Image <img src="'. $yourVariable.'"/>'; ...
rbock
  • 625
  • 5
  • 15
0

Your ' and " were in the wrong spots. Also, not that it's related to your PHP erorr but you were also missing the < /> around your image.

echo 'Image: <img src="' . $page->image . '" alt=""/></br>';
Blueline
  • 388
  • 1
  • 10