hofo
hofo

Reputation: 522

Getting newlines instead of slash-f-s when echoing RTF from PHP

I'm migrating a old (circa 2001) PHP 3 app to a new PHP5 server. 90% of the code worked right out of the box after migration and most of the remaining bit worked once I went through the old php.ini and changed settings in the new php.ini to match. Still there's one really annoying thing. One of the major things the app does is create RTF documents by mashing together information from the MySQL database and RTF templates that are embedded in php scripts. The original author used echo statements that have PHP variable references and RTF mixed together to output a file to the browser, which then calls Word to handle the output.

My problem is that in the new system whenever the echo statement has \f, the actual output has a linebreak. I'm not certain if it is a CR or LF but it's definitely a linebreak. Is this a PHP thing to process the \f? How can I turn it off?

Upvotes: 1

Views: 286

Answers (2)

paracycle
paracycle

Reputation: 7850

According to the PHP documentation the "\f" in a double-quoted string stands for a FORM-FEED since version 5.2.5.

Thus, if you want to actually have "\f" in your output, you will need to use "\\f", as in:

echo "Test\\f";

Upvotes: 1

Tony Miller
Tony Miller

Reputation: 9159

\f is a form feed. It's equivalent to the ASCII code 12. See the full table at Wikipedia. If you were to print your RTF doc the printer should go to the next page. If you are looking at the document in a WYSIWYG editor such as Microsoft Word, it should show that the doc skips to the next page.

The \f is not a PHP thing specifically. If you don't actually want form feeds, get rid of the \f's.

Upvotes: 0

Related Questions