I am trying to write code that passes a php variable as a textboxes value. Here is the following code I tried:
echo "<td>"."<input type='text' value='<?php echo $start_date; ?>'/>"."</td>"
This brings up an error : Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';'
I have tried various methods of re-wording:
echo "<input type='text' value='<?php echo $start_date?>'/>";
(this was purely to test as I would like the result in a table row)
but this shows:
<?php echo ?>
in the textbox and I also get this error: Notice: Undefined variable: start_date...
Thanks in advance for any help.
You can try this-
You don't need to start one
echo
within another. The variable$start_date
can be within double quotes and hence interpolated.EDIT:
In case of an associative array, for example, to echo
$row['start_date']
Use this:
you have to echo once, for example:
You should always took thin in your mind that if you enclose a variable inside "" double quotes than it can be echoed directly. You don't need use concatenation for this only. Eg
In this as @Cthulhu said use it like that.