0

Every time specifying a path, i have to add additional '\' characters. Is there a way we can have specify path

$path=@"C:\Users\Documents";//need this is php

instead of

$path="C:\\Users\\Documents";

Thanks in advance for sharing inputs

NOTE: Not looking for dirname().

SBI
  • 2,322
  • 1
  • 17
  • 17
Ronak Agrawal
  • 1,006
  • 1
  • 19
  • 48

2 Answers2

7

Yes, using single quotes

$path = 'C:\Users\Documents';

this may be useful: What is the difference between single-quoted and double-quoted strings in PHP?

Community
  • 1
  • 1
Daniele D
  • 838
  • 1
  • 8
  • 21
3

You can use single quoted strings. These don't handle escape sequences such as \n \r. You can compare the functionality of single quoted php strings with the behaviour in C# according to the respective documentation pages. In C#, @"" strings are called verbatim strings.

PHP String Documentation

MSDN String Class

$string_without_escape_sequence = '\t\n\r';
SBI
  • 2,322
  • 1
  • 17
  • 17