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 </td>
<td>
<input name="nombre" value="<?php=$nombre?>" type="text" id="nombre" />
</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 </td> <td><input name="nombre" value="<?php echo $nombre?>" type="text" id="nombre" /> </td>
</tr></table>
</form>
精彩评论