What does a \ (backslash) do in PHP (5.3+)?

后端 未结 4 1506
长情又很酷
长情又很酷 2020-11-22 16:22

What does a \\ do in PHP?

For example, CSRF4PHP has \\FALSE, \\session_id, and \\Exception:

publi         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 16:59

    To clarify potential confusion:

    The backslash does not imply class inheritance.

    In the following, Animal, Dog, Shepherd don't have to be classes, but simply namespaces. Meaning something used to group names together to avoid naming collisions.

    $myDog = new \Animal\Dog\Shepherd\GermanShepherd();
    

    The leading \ means Animal was declared in the global scope.

提交回复
热议问题