Reply to Re: single quote in string constant

Your name:

Reply:


Posted by MangroveRoot on 12/03/07 00:26

J.O. Aho wrote:
> MangroveRoot wrote:
>
>> ======
>> <?php
>> echo "<TITLE>";
>> echo $title;
>> echo "'</TITLE>";
>> ?>
> This should result in a title: Doesn't Matter'
> Not what you really wanted, just drop the single quote at the end tag of title.

Yeah, I caught that only after my original post.
The extra singlequote in that place didn't really hurt anything,
but it prevented the desired result, and muddied the waters as well.
As you say, "just drop the single quote", and I'm golden.


> You seem to be over using the echo function too, why not just
> <h1><img src="foo.gif" alt="<?PHP echo $title; ?"></h1>

Well, yeah. I'm just starting out, and cutting and pasting
and editing examples. I'm not sure (yet) whether I like embedding PHP
in the middle of HTML tags like that, because it tends to get lost.
But then, if an HTML tag (like <img ...> starts to get long,
I typically format it very formally over several lines, e.g.
<img src="foo.gif"
alt="<?PHP echo $title; ?"
border="blah blah">
(BTW, there's an error here: The end of the alt tag is
?"
but should be
?>"
)


> of course you can use short tags for the php, but these may be removed in php6.

If you would direct me to a site that explains short tags,
I would be glad of it,
although it sounds like a habit I don't want to get into.


> When you use single quotes around a string you want to echo, you tell php to
> not parse the string at all, just echo it as it is. Double quotes tells that
> you want the string to be parsed and variables replaced with the value.

Yeah, I was afraid of something like that, but I'm glad you confirmed it.

[Back to original 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

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