PHP學習筆記:對命名空間(namespace)學習資料的翻譯

來源:互聯網
上載者:User

標籤:

Name collisions means:  you create a function named db_connect, and somebody elses code that you use in your file (i.e. an include) has the same function with the same name. To get around that problem, you rename your function SteveWa_db_connect  which makes your code longer and harder to read. Now you can use namespaces to keep your function name separate from anyone else‘s function name, and you won‘t have to make extra_long_named functions to get around the name collision problem. So a namespace is like a pointer to a file path where you can find the source of the function you are working with 

  (譯文)名字衝突意味著:

    你建立了一個函數named db_connect,然後你用了某個跟你有相同函數名的代碼(例如:一個include)。為瞭解決函數名衝突的問題,你把原來的函數named db_connect重新命名為SteveWa_db_connect,這種形式讓你的名字更加長,而且更難閱讀。

    現在你使用命名空間namespaces來確保你的函數named db_connect跟另外一個你引用的同名函數區分開,與此同時你不需要額外的長首碼來解決函數名衝突。所以,命名空間namespace更像一個檔案指路者,來卻把你想用的檔案路徑是正確的。

 

PHP學習筆記:對命名空間(namespace)學習資料的翻譯

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.