Chen Chiu
Chen Chiu

Reputation: 47

HTML img in PHP variable

Im trying to do this

$input = "<img src="HTML/images/user.png" alt="" />";

but it does not work out, i know im supposed to put a / before a " or something please help

Upvotes: 2

Views: 915

Answers (4)

Dipesh Parmar
Dipesh Parmar

Reputation: 27364

all you need to do is escape double quote. just like below.
\"HTML/images/user.png\" alt=\"\"

Upvotes: 1

user7282
user7282

Reputation: 5196

Try this

$input = "<img src='HTML/images/user.png' alt='' />";

Upvotes: 0

Roger Ng
Roger Ng

Reputation: 779

Note that you have use " for PHP already.

You can either choose to use ' or \".

For example,

$input = "<img src='HTML/images/user.png' alt='' />";

$input = "<img src=\"HTML/images/user.png\" alt=\"\" />";

Upvotes: 0

Dr. Dan
Dr. Dan

Reputation: 2288

Try this

$input = "<img src='HTML/images/user.png' alt='' />";

Or

$input = "<img src=\"HTML/images/user.png\" alt=\"\" />";

Upvotes: 4

Related Questions