A
A
AlexKuznec2016-06-15 11:40:44
Yii
AlexKuznec, 2016-06-15 11:40:44

What is the difference between Yii::$app and \Yii::$app?

What role does the slash play? From time to time I meet different spellings, but I did not find the answer in the documentation.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2016-06-15
@AlexKuznec

Yii::$app - used when the namespace is included via use;
\Yii::$app - used when the namespace is included directly in the code. Actually, the slash before Yii indicates that in order to include this namespace, you need to go beyond the current one.

A
Anatoly Medvedev, 2016-06-15
@balamyt92

php.net/manual/en/language.namespaces.global.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question