PHP ʖ²ἯTH
º/A
Ղ 14. ӫ¶ԏD
¹¹Ԭº¯ʽ
עҢ
PHP 3 º͠PHP4 µĹ¹Ԭº¯ʽӐ˹²»ͬ¡£PHP 4 µē¸ÿ¡¡£
// Works in PHP 3 and PHP 4. class Auto_Cart extends Cart {function Auto_Cart() {$this- add_item ("10", 1);}}
// Works in PHP 3 and PHP 4. class Constructor_Cart extends Cart {function Constructor_Cart($item = "10", $num = 1) {$this- add_item ($item, $num);}} // Shop the same old boring stuff. $default_cart = new Constructor_Cart; // Shop for real... $different_cart = new Constructor_Cart("20", 17);
עҢ
PHP 3£¬ʼnɺ º¹Ԭº¯ʽӐЭ¶Ϟֆ¡£אϸԄ¶Oз¶=Ҕ-½╢ЩϞֆ¡£
class A {function A() {echo "I am the constructor of A. br \n";}} class B extends A {function C() {echo "I am a regular function. br \n";}} // no constructor is being called in PHP 3. $b = new B;
class A {function A() {echo "I am the constructor of A. br \n";} function B() {echo "I am a regular function named B in class A. br \n"; echo "I am not a constructor in A. br \n";}} class B extends A {function C() {echo "I am a regular function. br \n";}} // This will call B() as a constructor. $b = new B;
עҢ
º/A
ưµ㼯A
¼̳м/TT
ɏһ¼¶
::