Mo Star Mo Star - 2 years ago 119
PHP Question

echo html in php with input value as php variable

I am very new to PHP and can't seem to get the following to work. Any help would be appreciated. I am trying to echo a HTML input field and set the value to a variable.

echo "<input type='hidden' name='item_name' value='<?php echo $one.$two; ?>'>" ;

What's wrong with this? When I inspect it on the page it does not show the value of the variable.

Answer Source

You must do like this

echo "<input type='hidden' name='item_name' value='".$one.$two."'>" ;

Strings and variables are connected with .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download