Realitätsverlust
Realitätsverlust

Reputation: 3953

Backslash before an argument or value

The title is a bit vague, but i don't know how to express the thought in one sentence:

I just stumbled across these two lines here:

catch (\Exception $e)

and

return new \SFW();

What exactly is this backslash doing there? I've never seen or used it in any of my projects and wondering what is the usage of it.

Upvotes: 0

Views: 67

Answers (1)

deceze
deceze

Reputation: 522005

This is part of the namespace syntax and allows you to refer to items in the global namespace from within a local namespace. See http://php.net/namespaces. E.g.:

namespace Foo;

class Exception { }

new Exception;  // Foo\Exception
new \Exception; // global Exception

Upvotes: 1

Related Questions