On a form I have a text input and I am attempting to add as the value a php statement using an echo with a sting (e.g. <td><input type =text name =mystring maxlength =30 size =40 value = <?php echo "This is a test"; ?> ></td>
I only get "This" as the value and not any of the other words. Why is this and how do I correct it?
html input with a php echo string?
Use correct markups (quotes are your friend).
This should do what you expect:
<td><input type='text' name='mystring' maxlength=30 size=40 value='<?php echo "This is a test"; ?>'></td>
Ahhh, in all my reading I never came across this or probably more likely, never comprehended this. Thanks.
correct me if I am wrong but should those not be
<input type="text" name="mystring" maxlength="30" size="40" value="<?php echo ("This is a test"); ?>"></td>
Works either way. Technically you are correct in quoting the numbers too, but single quotes are the 'standard' method (if there is such a thing in the messy world of HTML specs)
really, I could have sworen that double quote was standard...all these years
Well, the W3C allows either to be used. I've never seen them use single quotes around attribute values myself, either in their specification documents or in the source of their own pages.
I've been wrong before... I didn't mean to start a serious debate here.
Majik wrote:
Use correct markups (quotes are your friend).
This should do what you expect:
<td><input type='text' name='mystring' maxlength=30 size=40 value='<?php echo "This is a test"; ?>'></td>
if value = '<?php echo "this is another
quote's tset"; ?>'
How to escape the single quote (') in
the string