小编isr*_*php的帖子

当使用自我,父母,静态和如何?

如果到现在我对ststic有点了解现在我意识到我什么都不懂.我很困惑,我很难理解,我不能.有人可以在使用self,parent,static时解释这个程序,以及我所做的所有最小的改变都会改变结果而不会让我无法理解正在发生的事情.非常感谢 ..

来自http://docs.php.net/language.oop5.late-static-bindings的代码

<?php
class A {
    public static function foo() {
        static::who();
    }

    public static function who() {
        echo __CLASS__."\n";
    }
}

class B extends A {
    public static function test() {
        A::foo();
        parent::foo();
        self::foo();
    }

    public static function who() {
        echo __CLASS__."\n";
    }
}
class C extends B {
    public static function who() {
        echo __CLASS__."\n";
    }
}

C::test();
?>
Run Code Online (Sandbox Code Playgroud)

出局是:

A
C
C
Run Code Online (Sandbox Code Playgroud)

php oop static

13
推荐指数
3
解决办法
1万
查看次数

css background-repeat x和y

是否可以使用小图片为背景div重复x和y? 见示例谢谢.

html css

11
推荐指数
2
解决办法
4万
查看次数

我为什么需要"&"?

请参阅Web上有关PHP Factory Pattern的示例.

在线$kind =& Vehicle::category($wheel);,我为什么要使用&

代码:

<?php
    class Vehicle {

        function category($wheel = 0) {
            if ($wheel == 2) {
                return "Motor";
            } elseif($wheel == 4) {
                return "Car";
            }
        }
    }

    class Spec {

        var $wheel = '';

        function Spec($wheel) {
            $this->wheel = $wheel;
        }

        function name() {
            $wheel = $this->wheel;
                return Vehicle::category($wheel);
        }

        function brand() {
            $wheel = $this->wheel;
                $kind =& Vehicle::category($wheel);
            if ($kind == "Motor") {
                return array('Harley','Honda');
            } elseif($kind = "Car") …
Run Code Online (Sandbox Code Playgroud)

php oop

4
推荐指数
1
解决办法
154
查看次数

标签 统计

oop ×2

php ×2

css ×1

html ×1

static ×1