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

  • 相关阅读:
    ES6 import、export的写法
    不带分号可能会引起出错的情况
    npm传参技巧
    深度优先遍历和广度优先遍历
    WebGL的shader
    web component
    页面的beforeunload和unload的事件应用
    暴搜
    子集树与排列树
    概率论
  • 原文地址:https://www.cnblogs.com/jianqingwang/p/5923313.html
Copyright © 2011-2022 走看看