How to replace backslash in php with xml?

I am trying to create an xml file from php .... it does not work properly ... when I eentered \ notepad \ text, it creates in the xml file as otepad ext ....

what is the solution for this problem? can i use any function for this?

+3
source share
2 answers

When you write it like this:

echo "\notepad\text";

\nwill be interpreted as a new line and \tas a tab.

Try single quotes:

echo '\notepad\text';

or print backslash characters:

echo "\\notepad\\text";
+3
source

You can replace them with a constant DIRECTORY_SEPARATOR.

Or just use slashes and

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

To make this constant less cumbersome, you can do it

define('DS', DIRECTORY_SEPARATOR);

Joomla does it.

, , escape-.

, str_replace() .

0

Source: https://habr.com/ru/post/1743453/


All Articles