I'm trying to directly use php scripts at the html attributes. I'm using the following code to show some text on the text box.
<input type="text" name="name" value="<?php echo "name";?>"/><br/>
But, it shows <?php echo
on the text box. I've seen at W3Schools and changed it to "<?php echo $name;?>"
. Now it shows <?php echo $name;?>
on the text box.
I'm confused. How to use php
to show some text on the value attribute of input type?
Make sure that your file is php
not the html
file.If your file extension is .html
then change it to .php
and try it.And also try to change like :
<input type="text" name="name" value="<?php echo 'name';?>"/><br/>
You cont use double quotes in the double quotes.Change them to single quotes
.
Note : Also you can use tpl
/phtml
files also but with extension .tpl
/.phtml
.
you should use
<input type="text" name="name" value="<?php echo 'name';?>"/>
use single contention not double contention in php echo
for more tutorial visit http://w3webtutorial.blogspot.com/
<?php
$name="name";
?>
<input type="text" name="name" value="<?php echo $name;?>" placeholder="haiiii"/>
you can't able to write php code in html page, but you can write html in php page.