You are here: Re: How do you interpret single quote embedded in double quote embedded in single quote? « PHP Programming Language « IT news, forums, messages
Re: How do you interpret single quote embedded in double quote embedded in single quote?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация