|
Posted by John Dunlop on 03/25/06 14:27
Somebody:
[$myvar='TEST 123';]
> <input name="testbox1" type="text" value=<?php echo "$myvar"; ?>>
> the result is a form with a textbox with the default value "TEST"
You are obviously aware that the value must be within quotes in the
HTML, but if you look at the HTML source you'll see the value is not
quoted, which causes the value to be cut off after 'TEST'. PHP
interprets what's after echo here as a string delimited by double quote
marks, that string being the variable $myvar, and only the value of
that string, not the quote marks as well, is echo-ed.
Two options. Either include the quotes in the echo-ed string (there
are various ways) or include them directly in the markup. Given the
advice to always quote attribute values, the latter seems more
appropriate.
--
Jock
[Back to original message]
|