我剛剛在一個PHP對象的引用中看到了反斜槓的使用,並且對它很好奇(我以前從未見過)。這是什麼意思?PHP中的反斜槓 - 它是什麼意思?
$mail = new SendGrid\Mail();
如果您好奇,這裏是SendGrid's documentation。
我剛剛在一個PHP對象的引用中看到了反斜槓的使用,並且對它很好奇(我以前從未見過)。這是什麼意思?PHP中的反斜槓 - 它是什麼意思?
$mail = new SendGrid\Mail();
如果您好奇,這裏是SendGrid's documentation。
這是PHP的命名空間運算符:http://php.net/manual/en/language.namespaces.php。
不要問爲什麼這是一個反斜槓。這是(imho)他們可能做出的最愚蠢的選擇,他們的決定基於一種高度傾斜/極端的得分系統,只對開發者有意義。
這是名稱空間的語法。你可以在PHP documentation閱讀更多關於命名空間。他們至少需要PHP 5.3。
例如:
namespace SendGrid;
function Mail() {
// You can access this function by using SendGrid\Mail() externally
}
這是http://stackoverflow.com/questions/4075521/backslash-syntax-when-creating-objects的副本,這樣你就可以在那裏找到答案。 – 11684
@ 11684 yea剛纔看到那個... oops – Kyle
這個偉大的文章解釋了更多的細節http://stackoverflow.com/q/4790020/6521116 –