You are here: Re: single quote in string constant « PHP Language « IT news, forums, messages
Re: single quote in string constant

Posted by Ian Hobson on 12/02/07 20:12

MangroveRoot wrote:
> I've looked in various manuals and tutorials,
> and they cover the obvious situations, but not this one:
>
>
>
> Is there some way I can "escape" or "quote" the singlequote in the variable
> so that it will just be taken as a value (I guess)
> rather than as something to be concatenated with what's around it
> and thus interacting with the quotes around it?
Indeed there are many ways to do what you want.

I won't repeat the manual here - it does a reasonable job of explaining
the options - its just that there are so many it gets complicated.

What you need is either to escape the double quotes, and let the double
quote processing convert $var into its value. Here you echo a single
processed string, thus.

<?php echo "
<H1><IMG SRC=\"_images/_rock/Zacs World.gif\" ALT=\"$title\"></H1>
"; ?>

Or you can use single quotes, and the concatenation operator dot (.)
which joins the strings it appears between. This means you echo the join
of three strings thus.

<?php echo '
<H1><IMG SRC="_images/_rock/Zacs World.gif" ALT="'.$title.'"></H1>
'; ?>

Regards

Ian

 

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

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