What does the "\" mean in this PHP library?

$mail = new SendGrid\Mail(); 

I do not understand the value of \ between SendGrid and Mail() above the line. can someone tell me what it is and its logic.

+6
source share
1 answer

Defines a namespace. Therefore, the Mail library is in the SendGrid namespace. This is a feature only available in PHP 5.3+.

Basically a namespace is a way to limit the area in which you can have class names. This allows you to have classes with the same name in many different namespaces without clashing between class definitions. This is great for writing libraries because it makes sure that the end user of your library is not limited to your naming conventions.

+5
source

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


All Articles