# How do you make a string in PHP with a backslash in it?

PHPServer Side ProgrammingProgramming

When the backslash \ does not escape the terminating quote of the string or even create a valid escape sequence (in double quoted strings), then the below code can be used to produce one backslash −

## Example

Live Demo

$string = 'abc\def'; print($string);

## Output

This will produce the following output −

abc\def

## Example

Live Demo

$string = "abc\\def"; print($string);

## Output

This will produce the following output −

abc\def
Published on 09-Apr-2020 14:04:11