-1

Okay so i was wondering how i echo a variable from a database that i already have connected to a php script so basicly it would be like

echo '<img src="blablabla.com/VARIABLENAMEHERE" />'
Blake Cothran
  • 7
  • 1
  • 2
  • 6
  • Concatenate or use double quotes. If you use double quotes use single quotes to encapsulate your attributes. http://php.net/manual/en/language.operators.string.php http://www.phptherightway.com/pages/The-Basics.html – chris85 Jul 03 '15 at 01:29
  • possible duplicate of [How can I echo HTML in PHP?](http://stackoverflow.com/questions/1100354/how-can-i-echo-html-in-php) – kittykittybangbang Jul 03 '15 at 01:30

2 Answers2

1

Use double quotes, and then variables will be expanded inside the string:

echo "<img src='blablabla.com/$variable' />";

Or user string concatenation:

echo '<img src="blablabla.com/' . $variable . '" />';
Barmar
  • 741,623
  • 53
  • 500
  • 612
1

you can use double quotes as the double quotes evaluates the variable inside.

echo "<img src='blablabla.com/$variablename' />";

but if you insist using single quote you can use concatenation.

echo '<img src="blablabla.com/' . $variablename . '" />';
espongha
  • 225
  • 1
  • 13