placing "" within ""

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: ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-03-2006
ebakunin@gmail.com
 
Posts: n/a
Default placing "" within ""

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.

Reply With Quote
  #2 (permalink)  
Old 11-03-2006
aaron.reese@tiscali.co.uk
 
Posts: n/a
Default Re: placing "" within ""


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

Reply With Quote
  #3 (permalink)  
Old 11-03-2006
ebakunin@gmail.com
 
Posts: n/a
Default Re: placing "" within ""

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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:00 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0