single quote in string constant

single quote in string constant

am 02.12.2007 20:41:26 von scenic_man

I've looked in various manuals and tutorials,
and they cover the obvious situations, but not this one:

At the very top of my .php file, I define a variable as follows:
======
$title = "Doesn't Matter";
------
Note the apostrophe (or, single quote) in the string value.

Further down, in the ..., I have the following:
======
echo "";<br /> echo $title;<br /> echo "'";
?>
------
If I bookmark the page, the name is what I hoped: "Doesn't Matter".

Further down, in the ..., I have the following:
======

$title


"; ?>
------
This fails, producing only "Doesn" in whatever format corresponds to H1.
I'm guessing that's because the singlequote in the variable
is somehow interacting with the singlequotes in the echoed string.

However, if I try this:
======

$title


'; ?>
------
(which I perhaps prefer,
because the HTML looks the way I would like it to look)
this also fails, producing "$title" in whatever format corresponds to H1.

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?

I've tried doubling it and prefacing it with backslash,
but that just displays (if at all) as the same thing
only with an extra quote or with a backslash.

Re: single quote in string constant

am 02.12.2007 21:12:40 von Ian Hobson

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.

\"$title\"


"; ?>

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.

'.$title.'


'; ?>

Regards

Ian

Re: single quote in string constant

am 02.12.2007 21:12:40 von Ian Hobson

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.

\"$title\"


"; ?>

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.

'.$title.'


'; ?>

Regards

Ian

Re: single quote in string constant

am 02.12.2007 21:22:00 von Jerry Stuckle

MangroveRoot wrote:
> I've looked in various manuals and tutorials,
> and they cover the obvious situations, but not this one:
>
> At the very top of my .php file, I define a variable as follows:
> ======
> $title = "Doesn't Matter";
> ------
> Note the apostrophe (or, single quote) in the string value.
>
> Further down, in the ..., I have the following:
> ======
> > echo "";<br /> > echo $title;<br /> > echo "'";
> ?>
> ------
> If I bookmark the page, the name is what I hoped: "Doesn't Matter".
>
> Further down, in the ..., I have the following:
> ======
> >

$title


> "; ?>
> ------
> This fails, producing only "Doesn" in whatever format corresponds to H1.
> I'm guessing that's because the singlequote in the variable
> is somehow interacting with the singlequotes in the echoed string.
>
> However, if I try this:
> ======
> >

$title


> '; ?>
> ------
> (which I perhaps prefer,
> because the HTML looks the way I would like it to look)
> this also fails, producing "$title" in whatever format corresponds to H1.
>
> 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?
>
> I've tried doubling it and prefacing it with backslash,
> but that just displays (if at all) as the same thing
> only with an extra quote or with a backslash.

This isn't a PHP problem. Look at your page source and you'll see why
it's occurring.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: single quote in string constant

am 02.12.2007 21:22:00 von Jerry Stuckle

MangroveRoot wrote:
> I've looked in various manuals and tutorials,
> and they cover the obvious situations, but not this one:
>
> At the very top of my .php file, I define a variable as follows:
> ======
> $title = "Doesn't Matter";
> ------
> Note the apostrophe (or, single quote) in the string value.
>
> Further down, in the ..., I have the following:
> ======
> > echo "";<br /> > echo $title;<br /> > echo "'";
> ?>
> ------
> If I bookmark the page, the name is what I hoped: "Doesn't Matter".
>
> Further down, in the ..., I have the following:
> ======
> >

$title


> "; ?>
> ------
> This fails, producing only "Doesn" in whatever format corresponds to H1.
> I'm guessing that's because the singlequote in the variable
> is somehow interacting with the singlequotes in the echoed string.
>
> However, if I try this:
> ======
> >

$title


> '; ?>
> ------
> (which I perhaps prefer,
> because the HTML looks the way I would like it to look)
> this also fails, producing "$title" in whatever format corresponds to H1.
>
> 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?
>
> I've tried doubling it and prefacing it with backslash,
> but that just displays (if at all) as the same thing
> only with an extra quote or with a backslash.

This isn't a PHP problem. Look at your page source and you'll see why
it's occurring.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: single quote in string constant

am 02.12.2007 21:22:24 von luiheidsgoeroe

On Sun, 02 Dec 2007 20:41:26 +0100, MangroveRoot =

wrote:

> I've looked in various manuals and tutorials,
> and they cover the obvious situations, but not this one:
>
> At the very top of my .php file, I define a variable as follows:
> ======
> $title =3D "Doesn't Matter";

$title =3D htmlspecialchars($title,ENT_QUOTES);
-- =

Rik Wasmus

Re: single quote in string constant

am 02.12.2007 21:37:42 von Shion

MangroveRoot wrote:

> ======
> > echo "";<br /> > echo $title;<br /> > echo "'";
> ?>
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.

> Further down, in the ..., I have the following:
> ======
> >

$title


> "; ?>
> ------
> This fails, producing only "Doesn" in whatever format corresponds to H1.
> I'm guessing that's because the singlequote in the variable
> is somehow interacting with the singlequotes in the echoed string.

This for the web browsers parser will see the single quote in your string as
the end for the alt-option and the "t Matter'" as unknown options.
You can use double quotes for the tag options, there are still some
proletarian browsers which has trouble with single quoted tag options.

You seem to be over using the echo function too, why not just

<?PHP echo $title; ?



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


> However, if I try this:
> ======
> >

$title


> '; ?>
> ------

there is a difference between
echo '$omthing';
and
echo "$omething";

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.

even if
echo "$omething";
works, I would recommend you to use
echo "{$omething}";
as this way you will have less trouble that php parses the wrong variables
(wrong from your point of view).


> 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?

It's not a php problem, but the HTML syntax and as it don't take care of
escapes for quotes, you won't be able to do what you want to do, you need to
change the method you are using to a more sane one.


--

//Aho

Re: single quote in string constant

am 02.12.2007 21:37:42 von Shion

MangroveRoot wrote:

> ======
> > echo "";<br /> > echo $title;<br /> > echo "'";
> ?>
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.

> Further down, in the ..., I have the following:
> ======
> >

$title


> "; ?>
> ------
> This fails, producing only "Doesn" in whatever format corresponds to H1.
> I'm guessing that's because the singlequote in the variable
> is somehow interacting with the singlequotes in the echoed string.

This for the web browsers parser will see the single quote in your string as
the end for the alt-option and the "t Matter'" as unknown options.
You can use double quotes for the tag options, there are still some
proletarian browsers which has trouble with single quoted tag options.

You seem to be over using the echo function too, why not just

<?PHP echo $title; ?



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


> However, if I try this:
> ======
> >

$title


> '; ?>
> ------

there is a difference between
echo '$omthing';
and
echo "$omething";

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.

even if
echo "$omething";
works, I would recommend you to use
echo "{$omething}";
as this way you will have less trouble that php parses the wrong variables
(wrong from your point of view).


> 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?

It's not a php problem, but the HTML syntax and as it don't take care of
escapes for quotes, you won't be able to do what you want to do, you need to
change the method you are using to a more sane one.


--

//Aho

Re: single quote in string constant

am 02.12.2007 22:37:14 von Allodoxaphobia

On Sun, 02 Dec 2007 19:41:26 GMT, MangroveRoot wrote:
> I've looked in various manuals and tutorials,
> and they cover the obvious situations, but not this one:
>
> At the very top of my .php file, I define a variable as follows:
>======
> $title = "Doesn't Matter";

Not tested:

$title = "Doesn't Matter";

Re: single quote in string constant

am 02.12.2007 22:37:14 von Allodoxaphobia

On Sun, 02 Dec 2007 19:41:26 GMT, MangroveRoot wrote:
> I've looked in various manuals and tutorials,
> and they cover the obvious situations, but not this one:
>
> At the very top of my .php file, I define a variable as follows:
>======
> $title = "Doesn't Matter";

Not tested:

$title = "Doesn't Matter";

Re: single quote in string constant

am 03.12.2007 00:09:48 von scenic_man

Allodoxaphobia wrote:
>>
>> At the very top of my .php file, I define a variable as follows:
>> ======
>> $title = "Doesn't Matter";
>
> Not tested:
>
> $title = "Doesn't Matter";

This helps a great deal.
A *little* ugly, but only ugly in one place, not *everywhere*.
The explanation (as I see it) is that this ensures that
the punctuation mark indicating the contraction of "does not"
is an apostrope (which, grammatically, it's *supposed* to be)
and not just a singlequote
(which *happens* to look the same in most, if not all, fonts).

I then went on to use this:
======

{$title}


"; ?>
------
and it worked perfectly, demonstrating that the apostrophe
is not mistaken for a singlequote, and the two do not interact.

I went on further to use this:
======

\"{$title}\"


"; ?>
------
This way, the *generated* HTML has the more pleasing
(and, I gather, more backward-compatible) format.
The business of escaping all the doublequotes inside the quoted string
*does* get old after a while -- tiresome to do, prone to error, and ugly --
but it seems to be what most scripting languages do.

(Perl, sed, TECO, and probably others
allow the programmer to specify an alternate character
to quote the entire string, so that ordinary single *or* double quotes
may be used inside the string with impunity.)

Re: single quote in string constant

am 03.12.2007 00:09:48 von scenic_man

Allodoxaphobia wrote:
>>
>> At the very top of my .php file, I define a variable as follows:
>> ======
>> $title = "Doesn't Matter";
>
> Not tested:
>
> $title = "Doesn't Matter";

This helps a great deal.
A *little* ugly, but only ugly in one place, not *everywhere*.
The explanation (as I see it) is that this ensures that
the punctuation mark indicating the contraction of "does not"
is an apostrope (which, grammatically, it's *supposed* to be)
and not just a singlequote
(which *happens* to look the same in most, if not all, fonts).

I then went on to use this:
======

{$title}


"; ?>
------
and it worked perfectly, demonstrating that the apostrophe
is not mistaken for a singlequote, and the two do not interact.

I went on further to use this:
======

\"{$title}\"


"; ?>
------
This way, the *generated* HTML has the more pleasing
(and, I gather, more backward-compatible) format.
The business of escaping all the doublequotes inside the quoted string
*does* get old after a while -- tiresome to do, prone to error, and ugly --
but it seems to be what most scripting languages do.

(Perl, sed, TECO, and probably others
allow the programmer to specify an alternate character
to quote the entire string, so that ordinary single *or* double quotes
may be used inside the string with impunity.)

Re: single quote in string constant

am 03.12.2007 00:11:59 von scenic_man

MangroveRoot wrote:
> At the very top of my .php file, I define a variable as follows:
> ======
> $title = "Doesn't Matter";
> ------
> (. . .)
> 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?
> (. . .)

BTW, which of these groups --
alt.comp.lang.php, alt.php, comp.lang.php --
is the correct one for questions of this sort?

Re: single quote in string constant

am 03.12.2007 00:11:59 von scenic_man

MangroveRoot wrote:
> At the very top of my .php file, I define a variable as follows:
> ======
> $title = "Doesn't Matter";
> ------
> (. . .)
> 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?
> (. . .)

BTW, which of these groups --
alt.comp.lang.php, alt.php, comp.lang.php --
is the correct one for questions of this sort?

Re: single quote in string constant

am 03.12.2007 01:16:06 von Jerry Stuckle

MangroveRoot wrote:
> MangroveRoot wrote:
>> At the very top of my .php file, I define a variable as follows:
>> ======
>> $title = "Doesn't Matter";
>> ------
> > (. . .)
>> 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?
> > (. . .)
>
> BTW, which of these groups --
> alt.comp.lang.php, alt.php, comp.lang.php --
> is the correct one for questions of this sort?
>

None of them. This is an HTML problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: single quote in string constant

am 03.12.2007 01:16:06 von Jerry Stuckle

MangroveRoot wrote:
> MangroveRoot wrote:
>> At the very top of my .php file, I define a variable as follows:
>> ======
>> $title = "Doesn't Matter";
>> ------
> > (. . .)
>> 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?
> > (. . .)
>
> BTW, which of these groups --
> alt.comp.lang.php, alt.php, comp.lang.php --
> is the correct one for questions of this sort?
>

None of them. This is an HTML problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: single quote in string constant

am 03.12.2007 01:26:35 von scenic_man

J.O. Aho wrote:
> MangroveRoot wrote:
>
>> ======
>> >> echo "";<br /> >> echo $title;<br /> >> echo "'";
>> ?>
> 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
>

<?PHP echo $title; ?



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 starts to get long,
I typically format it very formally over several lines, e.g.
alt=" 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.

Re: single quote in string constant

am 03.12.2007 01:26:35 von scenic_man

J.O. Aho wrote:
> MangroveRoot wrote:
>
>> ======
>> >> echo "";<br /> >> echo $title;<br /> >> echo "'";
>> ?>
> 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
>

<?PHP echo $title; ?



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 starts to get long,
I typically format it very formally over several lines, e.g.
alt=" 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.

Re: single quote in string constant

am 03.12.2007 01:54:58 von Michael

MangroveRoot wrote:
> - SNIP -
> (Perl, sed, TECO, and probably others
> allow the programmer to specify an alternate character
> to quote the entire string, so that ordinary single *or* double quotes
> may be used inside the string with impunity.)

echo <<

{$title}


EOI
;

You could use the heredoc syntax?

However I only recommend it when you are using many single and double
quotes. In your example your string consists of only double quotes. I
would suggest doing:

echo '

' . $title . <br />
'

';

You should consider using a template engine to keep business logic and
design separate. I recommend Smarty (smarty.php.net).

- Michael

Re: single quote in string constant

am 03.12.2007 01:54:58 von Michael

MangroveRoot wrote:
> - SNIP -
> (Perl, sed, TECO, and probably others
> allow the programmer to specify an alternate character
> to quote the entire string, so that ordinary single *or* double quotes
> may be used inside the string with impunity.)

echo <<

{$title}


EOI
;

You could use the heredoc syntax?

However I only recommend it when you are using many single and double
quotes. In your example your string consists of only double quotes. I
would suggest doing:

echo '

' . $title . <br />
'

';

You should consider using a template engine to keep business logic and
design separate. I recommend Smarty (smarty.php.net).

- Michael

Re: single quote in string constant

am 03.12.2007 08:47:19 von Onideus Mad Hatter

On Sun, 02 Dec 2007 19:16:06 -0500, Jerry Stuckle
wrote:

>MangroveRoot wrote:
>> MangroveRoot wrote:
>>> At the very top of my .php file, I define a variable as follows:
>>> ======
>>> $title = "Doesn't Matter";
>>> ------
>> > (. . .)
>>> 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?
>> > (. . .)
>>
>> BTW, which of these groups --
>> alt.comp.lang.php, alt.php, comp.lang.php --
>> is the correct one for questions of this sort?
>>
>
>None of them. This is an HTML problem.

Ignore Jerry, he's the resident doofus around here. He likes to
pretend he knows how to code but he doesn't actually have any work in
the area. Either group is fine to ask yer question in.

--

Onideus Mad Hatter
mhm ¹ x ¹
http://www.backwater-productions.net
http://www.backwater-productions.net/hatter-blog


Hatter Quotes
-------------
"You're only one of the best if you're striving to become one of the
best."

"I didn't make reality, Sunshine, I just verbally bitch slapped you
with it."

"I'm not a professional, I'm an artist."

"Your Usenet blinders are my best friend."

"Usenet Filters - Learn to shut yourself the fuck up!"

"Drugs killed Jesus you know...oh wait, no, that was the Jews, my
bad."

"There are clingy things in the grass...burrs 'n such...mmmm..."

"The more I learn the more I'm killing my idols."

"Is it wrong to incur and then use the hate ridden, vengeful stupidity
of complete strangers in random Usenet froups to further my art?"

"Freedom is only a concept, like race it's merely a social construct
that doesn't really exist outside of your ability to convince others
of its relevancy."

"Next time slow up a lil, then maybe you won't jump the gun and start
creamin yer panties before it's time to pop the champagne proper."

"Reality is directly proportionate to how creative you are."

"People are pretty fucking high on themselves if they think that
they're just born with a soul. *snicker*...yeah, like they're just
givin em out for free."

"Quible, quible said the Hare. Quite a lot of quibling...everywhere.
So the Hare took a long stare and decided at best, to leave the rest,
to their merry little mess."

"There's a difference between 'bad' and 'so earth shatteringly
horrible it makes the angels scream in terror as they violently rip
their heads off, their blood spraying into the faces of a thousand
sweet innocent horrified children, who will forever have the terrible
images burned into their tiny little minds'."

"How sad that you're such a poor judge of style that you can't even
properly gauge the artistic worth of your own efforts."

"Those who record history are those who control history."

"I am the living embodiment of hell itself in all its tormentive rage,
endless suffering, unfathomable pain and unending horror...but you
don't get sent to me...I come for you."

"Ideally in a fight I'd want a BGM-109A with a W80 250 kiloton
tactical thermonuclear fusion based war head."

"Tell me, would you describe yourself more as a process or a
function?"

"Apparently this group has got the market cornered on stupid.
Intelligence is down 137 points across the board and the forecast
indicates an increase in Webtv users."

"Is my .sig delimiter broken? Really? You're sure? Awww,
gee...that's too bad...for YOU!" `, )

Re: single quote in string constant

am 03.12.2007 08:47:19 von Onideus Mad Hatter

On Sun, 02 Dec 2007 19:16:06 -0500, Jerry Stuckle
wrote:

>MangroveRoot wrote:
>> MangroveRoot wrote:
>>> At the very top of my .php file, I define a variable as follows:
>>> ======
>>> $title = "Doesn't Matter";
>>> ------
>> > (. . .)
>>> 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?
>> > (. . .)
>>
>> BTW, which of these groups --
>> alt.comp.lang.php, alt.php, comp.lang.php --
>> is the correct one for questions of this sort?
>>
>
>None of them. This is an HTML problem.

Ignore Jerry, he's the resident doofus around here. He likes to
pretend he knows how to code but he doesn't actually have any work in
the area. Either group is fine to ask yer question in.

--

Onideus Mad Hatter
mhm ¹ x ¹
http://www.backwater-productions.net
http://www.backwater-productions.net/hatter-blog


Hatter Quotes
-------------
"You're only one of the best if you're striving to become one of the
best."

"I didn't make reality, Sunshine, I just verbally bitch slapped you
with it."

"I'm not a professional, I'm an artist."

"Your Usenet blinders are my best friend."

"Usenet Filters - Learn to shut yourself the fuck up!"

"Drugs killed Jesus you know...oh wait, no, that was the Jews, my
bad."

"There are clingy things in the grass...burrs 'n such...mmmm..."

"The more I learn the more I'm killing my idols."

"Is it wrong to incur and then use the hate ridden, vengeful stupidity
of complete strangers in random Usenet froups to further my art?"

"Freedom is only a concept, like race it's merely a social construct
that doesn't really exist outside of your ability to convince others
of its relevancy."

"Next time slow up a lil, then maybe you won't jump the gun and start
creamin yer panties before it's time to pop the champagne proper."

"Reality is directly proportionate to how creative you are."

"People are pretty fucking high on themselves if they think that
they're just born with a soul. *snicker*...yeah, like they're just
givin em out for free."

"Quible, quible said the Hare. Quite a lot of quibling...everywhere.
So the Hare took a long stare and decided at best, to leave the rest,
to their merry little mess."

"There's a difference between 'bad' and 'so earth shatteringly
horrible it makes the angels scream in terror as they violently rip
their heads off, their blood spraying into the faces of a thousand
sweet innocent horrified children, who will forever have the terrible
images burned into their tiny little minds'."

"How sad that you're such a poor judge of style that you can't even
properly gauge the artistic worth of your own efforts."

"Those who record history are those who control history."

"I am the living embodiment of hell itself in all its tormentive rage,
endless suffering, unfathomable pain and unending horror...but you
don't get sent to me...I come for you."

"Ideally in a fight I'd want a BGM-109A with a W80 250 kiloton
tactical thermonuclear fusion based war head."

"Tell me, would you describe yourself more as a process or a
function?"

"Apparently this group has got the market cornered on stupid.
Intelligence is down 137 points across the board and the forecast
indicates an increase in Webtv users."

"Is my .sig delimiter broken? Really? You're sure? Awww,
gee...that's too bad...for YOU!" `, )

Re: single quote in string constant

am 07.12.2007 14:02:54 von Steve

MangroveRoot wrote in
news:GTD4j.3905$xB.1284@trndny06:

> I've looked in various manuals and tutorials,
> and they cover the obvious situations, but not this one:
>
> At the very top of my .php file, I define a variable as follows:
> ======
> $title = "Doesn't Matter";
> ------
> Note the apostrophe (or, single quote) in the string value.
>
> Further down, in the ..., I have the following:
> ======
> > echo "";<br /> > echo $title;<br /> > echo "'";
> ?>
> ------
> If I bookmark the page, the name is what I hoped: "Doesn't Matter".
>
> Further down, in the ..., I have the following:
> ======
> >

$title


> "; ?>
> ------
> This fails, producing only "Doesn" in whatever format corresponds to
> H1. I'm guessing that's because the singlequote in the variable
> is somehow interacting with the singlequotes in the echoed string.
>
> However, if I try this:
> ======
> >

$title


> '; ?>
> ------
> (which I perhaps prefer,
> because the HTML looks the way I would like it to look)
> this also fails, producing "$title" in whatever format corresponds to
> H1.
>
> 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?
>
> I've tried doubling it and prefacing it with backslash,
> but that just displays (if at all) as the same thing
> only with an extra quote or with a backslash.
>
>
> ---
> avast! Antivirus: Inbound message clean.
> Virus Database (VPS): 071206-0, 06/12/2007
> Tested on: 07/12/2007 12:58:16
> avast! - copyright (c) 1988-2007 ALWIL Software.
> http://www.avast.com
>
>
>
>

it can get frustrating. But this is what i do to solve this.
note the two type of quotes used single ' and double "

$title = "This'll work";

echo '

' . $title . '

';


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 071206-0, 06/12/2007
Tested on: 07/12/2007 13:04:48
avast! - copyright (c) 1988-2007 ALWIL Software.
http://www.avast.com

Re: single quote in string constant

am 07.12.2007 14:02:54 von Steve

MangroveRoot wrote in
news:GTD4j.3905$xB.1284@trndny06:

> I've looked in various manuals and tutorials,
> and they cover the obvious situations, but not this one:
>
> At the very top of my .php file, I define a variable as follows:
> ======
> $title = "Doesn't Matter";
> ------
> Note the apostrophe (or, single quote) in the string value.
>
> Further down, in the ..., I have the following:
> ======
> > echo "";<br /> > echo $title;<br /> > echo "'";
> ?>
> ------
> If I bookmark the page, the name is what I hoped: "Doesn't Matter".
>
> Further down, in the ..., I have the following:
> ======
> >

$title


> "; ?>
> ------
> This fails, producing only "Doesn" in whatever format corresponds to
> H1. I'm guessing that's because the singlequote in the variable
> is somehow interacting with the singlequotes in the echoed string.
>
> However, if I try this:
> ======
> >

$title


> '; ?>
> ------
> (which I perhaps prefer,
> because the HTML looks the way I would like it to look)
> this also fails, producing "$title" in whatever format corresponds to
> H1.
>
> 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?
>
> I've tried doubling it and prefacing it with backslash,
> but that just displays (if at all) as the same thing
> only with an extra quote or with a backslash.
>
>
> ---
> avast! Antivirus: Inbound message clean.
> Virus Database (VPS): 071206-0, 06/12/2007
> Tested on: 07/12/2007 12:58:16
> avast! - copyright (c) 1988-2007 ALWIL Software.
> http://www.avast.com
>
>
>
>

it can get frustrating. But this is what i do to solve this.
note the two type of quotes used single ' and double "

$title = "This'll work";

echo '

' . $title . '

';


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 071206-0, 06/12/2007
Tested on: 07/12/2007 13:04:48
avast! - copyright (c) 1988-2007 ALWIL Software.
http://www.avast.com

Re: single quote in string constant

am 07.12.2007 15:47:01 von Michael Fesser

..oO(Steve)

>it can get frustrating. But this is what i do to solve this.
>note the two type of quotes used single ' and double "
>
>$title = "This'll work";

$title .= ', but not on my 19" screen.';

SCNR

>echo '

' . $title . '
>

';

The correct solution (htmlspecialchars()) was posted already.

Micha

Re: single quote in string constant

am 07.12.2007 15:47:01 von Michael Fesser

..oO(Steve)

>it can get frustrating. But this is what i do to solve this.
>note the two type of quotes used single ' and double "
>
>$title = "This'll work";

$title .= ', but not on my 19" screen.';

SCNR

>echo '

' . $title . '
>

';

The correct solution (htmlspecialchars()) was posted already.

Micha