Welcome to Geeklog, Anonymous Thursday, April 17 2025 @ 02:45 pm EDT
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?
5
8
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
8
11
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.
10
7
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'
12
9
Quote
All times are EDT. The time is now 02:45 pm.
- 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