PHP variable in HTML

Posted by Shek on April 17, 2008 under PHP | Be the First to Comment | Total View: 4,463 views

There are many times that you might like to use or include PHP variables within HTML codes, case like to use for a text box’s name, and the way to do so is:


Lets say you want to have a text box with name “namebox” and you want to use the PHP variable $textboxname to store the name, then you want to use the name for a HTML text field element:

1
2
3
4
<?php
$textboxname = namebox;
?>
<input type="text" name="<?php echo $textboxname;?>"/>

Don’t forget to included <?php and ?> to make it as a PHP statement.

Not what you want? Try a Search

Add A Comment

*