|
Posted by tomzam on 07/28/07 16:34
On Jul 28, 11:33 am, Reporter <TruckSaf...@gmail.com> wrote:
> I got the following example fromhttp://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/inde...
> :
>
> echo '<tr><td>First name:</td><td><input type="text" name="first_name"
> value="'.htmlspecialchars($_POST['first_name']).'"></td></tr>';
>
> What purpose do the single quotes serve in
> value="'.htmlspecialchars($_POST['first_name']).'"
>
> I don't mean the single quotes around first_name. I mean the single
> quotes before and after the periods.
I am by no means a PHP expert, but I believe you are being misled by
an assumption. The assumption that something is wrong about the single
quotes. That's not the case.
What you have here is a single quoted string that is concatinated to
the result of the htmlspecialchars function, which in turn is
concatinated to another single quted string.
To make thsi clearer remember that the period (.) is the
concatination operator is PHP.
The quotes that are embeded in the strings are the double quotes
(")and the reason for them is that they are required by the html
that is being echoed out.
Finally, the single quotes around the 'first_name' are not embeded
in any string, they are there to make the string 'first_name' the key
(or index) to get thea appropriate value out of the $_POST[] array.
HTH,
- Tom Z
Navigation:
[Reply to this message]
|