zoukankan      html  css  js  c++  java
  • PHP学习笔记:对命名空间(namespace)学习资料的翻译

    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更像一个文件指路者,来却把你想用的文件路径是正确的。

  • 相关阅读:
    StarUML
    第二周周二日报
    第二周周一日报
    第一周周末报
    第一周周四日报
    第一周第三天日报
    软件开发总结
    构建之法总结
    《构建之法》第六章
    个人日志7
  • 原文地址:https://www.cnblogs.com/jianqingwang/p/5923313.html
Copyright © 2011-2022 走看看