-6

I have some newbie questions, but I can't easily search for those operators using google therefore hope somebody can help me with.

  1. What is the operator :: used for?
  2. Is there a different between "" and '' for string
  3. I saw \exception, what is \ used for?
william007
  • 17,375
  • 25
  • 118
  • 194
  • You can use [Symbolhound](http://symbolhound.com/?q=PHP+::+operator) instead of Google when searching for language tokens. – mario Mar 22 '13 at 03:55

2 Answers2

2

1. What is the operator :: used for?

It's the scope resolution operator.

2. Is there a different between "" and '' for string

Yes. Double quotes allow interpolation and special characters such as \n. Single quotes don't treat the string special.

3. I saw \exception, what is \ used for?

\ is the namespace operator.

alex
  • 479,566
  • 201
  • 878
  • 984
1

1.Sometimes it is useful to refer to functions and variables in base classes or to refer to functions in classes that have not yet any instances. The :: operator is being used for this.

Refer:http://php.net/manual/en/keyword.paamayim-nekudotayim.php

2.

Single quoted

The simplest way to specify a string is to enclose it in single quotes (the character ').

Double quoted

If the string is enclosed in double-quotes ("), PHP will interpret more escape sequences for special characters.

Refer:http://php.net/manual/en/language.types.string.php

3.Answer is here Importing classes and namespaces in PHP: What difference does a leading backslash make?

Community
  • 1
  • 1
Soojoo
  • 2,146
  • 1
  • 30
  • 56