I want to generate a simple html form and add some text box to it, then I want to define some php variables and use them as value for text boxes but when I try to use them it does not work and the value of variable would not be set for the text box. Would you please tell me about the correct syntax and the way for doing this
<?php
$foo = 123;
?>
<html>
<head>
</head>
<body>
<form Id='Form' Method='post' Action='http://example.com'>
fooElement<input type='text' name='fooElement' value='<?= $foo ?>'/>
</form>
</body>
</html>
How can i set the value of foo variable as the value for foo element?
Are you sure that your
short_open_tagis on?If not try to use
<php echo $foo;?>You have missing
?symbol.My advice: Be attentive while writing code. Try to check your code once more for typos and etc. before asking on SO. And learn this basics