Search code examples
phpstringrtf

Edit RTF, literal text in PHP


I'm creating a system that edits a .rtf file

the editing is done using plain text

I would like to put some string inside my php code to insert inside the rtf that comes from the system

 $ReplaceDois = "{\rtlch\fcs1 \af1\afs24
\ltrch\fcs0 \b\fs24\cf0\cgrid0\insrsid5259994\charrsid5461623 A \endash QUALIFICA'c7'c3O DAS PARTES\par}"

this is just an example, but I need to insert long texts like this

The problem is that php doesn't interpret literally

when i use double quotes i have problems with

\r \f and others

when i use single quotes I have problems with

QUALIFICA'c7'c3O

is there any way i can put my string and there is no escape in the text

the process of editing these files is a bit complicated, so I would like to be able to take the text from inside the rtf file and paste it into my code

Thank you for any help


Solution

  • Use heredoc strings :

    $ReplaceDois = <<<'eortf'
    {\rtlch\fcs1 \af1\afs24
    \ltrch\fcs0 \b\fs24\cf0\cgrid0\insrsid5259994\charrsid5461623 A \endash QUALIFICA'c7'c3O DAS PARTES\par}
    eortf;