Whether it's writing JavaScript or PHP, you're always used to using single quotes. But the weekend at home coding encountered a problem, you need to filter the string in the PHP line of characters, follow the following method:
$out = str_replace (Array (' RN ', ' r ', ' n '), ', $out); PHP provides three ways to define strings: single quotes, double quotes, and local documents (English is called here Document or Heredoc).
Single quotation mark:
Using single quotes is the most efficient method, because PHP does not check the built-in variables and escape sequences in the single quote string, and only the characters that need to be escaped are backslashes and single quotes themselves.
Double quotes:
Built-in variables and escape sequences are checked, but escaped single quotes are not recognized. This also illustrates the error of starting the code, and the right thing to do is to use double quotes to define the escape sequence for the newline:
$out = Str_replace (Array ("RN", "R", "N"), ", $out); Local document:
Check all built-in variables and escape sequences, and double quotes do not need to be escaped. For example:
Echo <<
This is a ' here document ' example.
Just for Test.
EOT, simple record, deepen the impression.