Jump to content

\t problems in a fwrite command


cve60069

Recommended Posts

If you put the PHP string within single-quotes they won't be parsed.

echo "\t"; // Prints a tabecho '\t'; // Prints "\t"echo "\\t" // Prints "\t" because the backslash is escaped.

Link to comment
Share on other sites

The problem with your RTF output is the opposite, PHP will see this:

{\rtf1\ansi\deff0 {\fonttbl {\f0 Courier;}}{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}\landscape\paperw15840\paperh12240\margl720\margr720\margt720\margb720\tx720\tx1440\tx2880\tx5760This line is the default color\line\tab this line has 1 tab\line\tab\tab this line has 2 tabs\line\tab\tab\tab this line has 3 tabs\line\tab\tab\tab\tab this line has 4 tabs\line\cf2\tab This line is red and has a tab before it\line\cf1}_END;

And convert every "\t" to a tab character, so instead of this: \tab This line is red and has a tab before it\line it will output this: <tab character>ab This line is red and has a tab before it\line Instead of using a heredoc you need to use a nowdoc, so that it does not convert the \t in "\tab" into an actual tab character. A nowdoc acts like a single-quoted string where a heredoc acts like a double-quoted string. To use a nowdoc instead of a heredoc you put the starting identifier in single quotes: $text = <<<'_END' That's the only change you need to make. I read Ingolme's reply wrong, we're talking about the same thing.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...