\Page::

Permalink 1 user found helpful
Hi,

What is the significance of the / before Page?

$parentPage = \Page::getByPath('/my/articles');

pvernaglia
 
razorcommerce replied on at Permalink Reply
razorcommerce
Namespaces can be preceded with a backslash (not a forward slash as suggested in this question which was probably a typo) so for anybody searching though the topic is "namespace preceding backslash".

Short answer is it means search global, rather than local. The particulars of what that means are not entirely clear to me either but it does mean in some places in C5 if you try to use only "use Page;" you'll get a fatal error something like "Compound use has no effect" which does not explain the issue, but the issue is that "Page" is not available in that local space. Whereas "use \Page;" will work anywhere.

I believe views are the main example of a place where you do need the global preceding backslash. In controllers however, that does not seem to be the case.

Personally I don't like the look of preceding the namespace so if I don't need to I don't.

http://stackoverflow.com/questions/4790020/what-does-a-backslash-do...