Welcome to Geeklog, Anonymous Saturday, January 17 2026 @ 11:53 am EST
Geeklog Forums
A PHP Question
Interested
Anonymous
I\'m afraid this will be such a dumb question I\'ll be ashamed to return to these forums. But I can\'t resist.
Having some difficulty understanding how to handle string variables.
Let\'s say we have the following:
$STRINGVAR = \'text group1 with \"double quotes\"\' . $stringvar1;
If stringvar1 = \'Jim\'s BBQ\' it causes problems. Is there a way to define $stringvar1 so that PHP doesn\'t mistake the single quote in Jim\'s to be a terminating quote in the overall argument?
I\'m I making sense?
Should I go back on my meds?
9
12
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
There are several ways to get around this. Instead of listing them, may I point you to the PHP manual instead?
bye, Dirk
13
16
Quote
Interested
Anonymous
Quote by Dirk: There are several ways to get around this. Instead of listing them, may I point you to the PHP manual instead?
bye, Dirk
Uh...thanks. I actually read the manual here. I don\'t think I understood it very well. I will be using an input variable that must allow for such things as single quotes. I tested my code by directly specifying a string with a value that contains a single quote. The code broke. When the single quote was removed, it worked perfectly.
I\'m not putting something together here. Ill just keep at it. Thanks again.
14
13
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by Interested:I will be using an input variable that must allow for such things as single quotes. I tested my code by directly specifying a string with a value that contains a single quote.
To use quotes within a quoted string, you need to escape it, e.g. Text Formatted Code
'Joe\'s Bar'
17
16
Quote
All times are EST. The time is now 11:53 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content