This is a discussion on placing "" within "" within the PHP General forums, part of the PHP Programming Forums category; OK, here's a tricky one. I have a block of text with double quotes ( " ) in it, something like: ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
OK, here's a tricky one.
I have a block of text with double quotes ( " ) in it, something like: John says "Hello" . Without altering the text, I need to place it in a string, which would look something like $str = " John says "Hello" ". Obviously this won't work. Since I cannot alter the text, I cannot change the double quotes into escape quotes (i.e " into \" ). So is there any way to put double quotes within double quotes? Thanks for the help. |
|
|||
|
That is exactly what the \" is for. The backslash tells the PHP parser to ignore the next character for parsing purposes and just output the contents Are you saying that you cannot do it because it is input from a file or becuase you need to output it to something else. You could use 'this is the string with "quotes" inside it' and surround the whole string with single quotes but you will not be able to use variables in the string because PHP will only convert $variables to their values inside double quoted strings. Obiron |
|
|||
|
The first option. I need to input a block of text **as is** and present
it **as is**, and the block of text could possibly include single or double quotes. A better example might be: John's wife says "Hello". Is there a function that can evaluate a block of text within parenthesis instead of using quotes? Thanks for the advice. On Nov 3, 3:49 am, aaron.re...@tiscali.co.uk wrote: > That is exactly what the \" is for. > > The backslash tells the PHP parser to ignore the next character for > parsing purposes and just output the contents > > Are you saying that you cannot do it because it is input from a file or > becuase you need to output it to something else. > > You could use 'this is the string with "quotes" inside it' > > and surround the whole string with single quotes but you will not be > able to use variables in the string because PHP will only convert > $variables to their values inside double quoted strings. > > Obiron |