How to assign string variable in php where string has both single and double quotes

Using PHP, I need to assign to a variable a long string that contains a number of single and double quotes which cause confusion when I surround the string with single or double quotes to contain it. I'm sure there must be a function to do this. However, search as I may, I cannot find one, nor contributors' solutions. These will be stored as files, not as DB records.

For example:
$string = 
"
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
line-height:normal;mso-outline-level:1'><b><span style='font-size:24.0pt;
font-family:"Times New Roman","serif";mso-fareast-font-family:"Times New Roman";
mso-font-kerning:18.0pt;mso-fareast-language:EN-CA'>Welcome Alpha Team!<o:p></o:p></span></b></p>
"

Open in new window


Clearly, the example can't work with Times New Roman contained by single or double quotes.

Is there a standard method to deal with this?
Torquil BeavisBusinessAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
You have to use 'escapes'.  The function 'addslashes' http://php.net/manual/en/function.addslashes.php will do that except of course, it is difficult to give it a string with both quotes.  The HEREDOC construct will handle both quotes.  On http://php.net/manual/en/language.types.string.php , see Heredoc.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Torquil BeavisBusinessAuthor Commented:
Thanks Dave. Perfect!
0
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.