我自己发现的php毛病是函数命名不规范,有的用下划线,有的又不用,有点乱,就不到规范正规一点儿吗?
如 file_put_contents()和fileattime()这两个,其中后面一个完全可以写成file_at_time()的嘛,看着也直观不知phper怎么看这事儿?

解决方案 »

  1.   

    不好意思,我理解错误,后面那个应该是fileatime(),即Gets last access time of file.
    不过就不能写成file_access_time()或file_a_time()吗?
      

  2.   

    你有无发现file_put_contents是PHP5新加入的
    而fileattime从PHP3就有了。
    历史遗留的问题
      

  3.   

    还有呀,stat()从字面好看真不好理解,此函数的功能是给出文件的信息,那为什么不用state()来命名呢,这不是更直观吗?
    stat?鬼知道什么意思,不是吗?
      

  4.   

    willko(珂),原来是这样啊,那php是在进步哈:)
      

  5.   

    php再怎么自由灵活,如果命名上也跟着自由,那只能是使得人的大脑受到连累了。
      

  6.   

    我感觉好的规范就要有好的编写习惯,我通常是参照adodb.inc.php这个文件的代码
    function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) 
    {
    if ($argHostname != "") $this->host = $argHostname;
    if ($argUsername != "") $this->user = $argUsername;
    if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons
    if ($argDatabaseName != "") $this->database = $argDatabaseName;

    $this->_isPersistentConnection = false;
    if ($forceNew) {
    if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true;
    } else {
     if ($rez=$this->_connect($this->host, $this->user, $this->password, $this->database)) return true;
    }
    if (isset($rez)) {
    $err = $this->ErrorMsg();
    if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'";
    $ret = false;
    } else {
    $err = "Missing extension for ".$this->dataProvider;
    $ret = 0;
    }
    if ($fn = $this->raiseErrorFn) 
    $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);


    $this->_connectionID = false;
    if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
    return $ret;
    }
      

  7.   

    很多都是c的api过来的,又加上一些其他软件比如mysql提供的api库,命名当然好不到哪去
      

  8.   

    挺方便的。内置function比较多
      

  9.   

    php和linux差不多
    一般情况下move都省作mov,偏偏linux省作mv。
    不过这样很有意思。
      

  10.   

    命名不规范后果很严重,感觉PHP的代码看起来很头晕