Zdravko Nikolov
Zdravko Nikolov

Reputation: 35

Input value in HTML

How do you a class id into an input field?

<input type="text" name="loc" value="<p id='test'>bb</p>" />

The example above doesn't work properly. Also, how do I put a PHP echo command in it.

Upvotes: 0

Views: 75

Answers (1)

John Conde
John Conde

Reputation: 219814

Use htmlentities()

<input type="text" name="loc" value="<?php echo htmlentities("<p id='test'>bb</p>"); ?>" />

The output will look like this:

<input type="text" name="loc" value="&lt;p id='test'&gt;bb&lt;/p&gt;" />

Upvotes: 1

Related Questions