开发者

PHP embed a variable in HTML

I am trying to embed a raw PHP variable $nombre into the HTML, here is the PHP:

Edit <?php e开发者_如何学JAVAcho $nombre; ?> .
<form action="getfile.php" method="post" name="uploadForm" id="uploadForm"
enctype="multipart/form-data"  ><br>

Complete the information below <br></br>
<table>
<tr>
<td>Nombre &nbsp;</td> 
<td>
  <input name="nombre" value="<?php=$nombre?>" type="text" id="nombre" />&nbsp;
</td>
</tr>
</table>

The first <?php echo $nombre; ?> shows the correct value, but inside <input> tag it prints blankstring. What am I doing wrong?


You have <?php=$nombre?> instead of <?=$nombre ?> or <?php echo $nombre ?> in your input tag.


I just tried the following code and it worked

<?php
$nombre = "hello"; 
?>

Let's edit  <?php echo $nombre; ?>.
<form action="getfile.php" method="post" name="uploadForm" id="uploadForm" enctype="multipart/form-data"  ><br>
Complete the information below <br></br>
    <table>
        <tr>
        <td>Nombre  &nbsp;</td> <td><input name="nombre" value="<?php echo $nombre?>" type="text" id="nombre" />&nbsp;</td>
        </tr></table>
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜