Backslash in PHP — what does it mean?

前端 未结 3 1853
广开言路
广开言路 2020-11-30 05:46

I just saw the use of a backslash in a reference to a PHP object and was curious about it (I have never seen this before). What does it mean?

$mail = new Sen         


        
相关标签:
3条回答
  • 2020-11-30 06:08

    It's because they're using PHP namespaces. Namespaces are new as of PHP 5.3.

    0 讨论(0)
  • 2020-11-30 06:15

    It's PHP's namespace operator: http://php.net/manual/en/language.namespaces.php.

    Don't ask why it's a backslash. It's (imho) the stupidest possible choice they could have made, basing their decisions on a highly slanted/bigoted scoring system that made sense only to the devs.

    0 讨论(0)
  • 2020-11-30 06:23

    This is syntax for namespaces. You can read more about namespaces at PHP documentation. They they require at least PHP 5.3.

    For example:

    namespace SendGrid;
    function Mail() {
        // You can access this function by using SendGrid\Mail() externally
    }
    
    0 讨论(0)
提交回复
热议问题