tags:

views:

157

answers:

2

I'm trying to create a xml file from php.... it is not work properly... when i eentered \notepad\text ,it creates in xml file as otepad ext....

what's the solution for this problem? can i use any function to this?

A: 

You can replace them with the constant DIRECTORY_SEPARATOR.

Or just use forward slashes and

$string = str_replace('/', DIRECTORY_SEPARATOR, $string);

To make using this constant less cumbersome, you can do this

define('DS', DIRECTORY_SEPARATOR);

Joomla does this.

If you want to skip the constant all together, you can probably also add an extra backslash to escape the escape character.

As for using a function, you can wrap that str_replace() above in a function.

alex
+2  A: 

When you write it this way:

echo "\notepad\text";

\n will be interpreted as a newline and \t as a tab.

Try single quotes:

echo '\notepad\text';

or escape the backslash characters:

echo "\\notepad\\text";
blinry