2014年12月1日 星期一

[PHP] parent::__construct()

class A {}
class B extends A {
    public function __construct() {
        parent::__construct(); // PHP Fatal error:  Cannot call constructor in test.php on line 5
    }
}
new B();

執行上面的程式會發生錯誤。

在 Java 這樣寫是合法的,由此可知 PHP 把 __construct() 當成一種特殊方法使用, 因此既有方法的功能,有又建構子的功能。

PHP 5.3.24 (cli) (built: Jun 10 2013 16:42:20)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.0rc1, Copyright (c) 2002-2012, by Derick Rethans

[Java] Invalid HTTP method: PATCH

最近系統需要使用 Netty4,所以把衝突的 Netty3 拆掉,然後就出現了例外。 pom.xml <dependency> <groupId>com.ning</groupId> <artifactId>as...