Heim  >  Artikel  >  Backend-Entwicklung  >  php生手:自学后台管理系统中

php生手:自学后台管理系统中

WBOY
WBOYOriginal
2016-06-13 12:22:481270Durchsuche

php新手:自学后台管理系统中

这句话是什么意思?那两个冒号是什么意思?新手一个,希望解释的清楚一点。
------解决思路----------------------
手册:
作用域分辨运算符(::)

注意 
下列内容仅在 PHP 4 及以后版本中有效。 
 

有时,在没有声明任何实例的情况下访问类中的函数或者基类中的函数和变量很有用处。而 :: 运算符即用于此情况。 


class A {
    function example() {
        echo "I am the original function A::example().
\n";
    }
}

class B extends A {
    function example() {
        echo "I am the redefined function B::example().
\n";
        A::example();
    }
}

// A 类没有对象,这将输出
//   I am the original function A::example().

A::example();

// 建立一个 B 类的对象
$b = new B;

// 这将输出
//   I am the redefined function B::example().

//   I am the original function A::example().

$b->example();
?>  


上面的例子调用了 A 类的函数 example(),但是这里并不存在 A 类的对象,因此不能这样用 $a->example() 或者类似的方法调用 example()。反而我们将 example() 作为一个类函数来调用,也就是说,作为一个类自身的函数来调用,而不是这个类的任何对象。 

这里有类函数,但没有类的变量。实际上,在调用函数时完全没有任何对象。因而一个类的函数可以不使用任何对象(但可以使用局部或者全局变量),并且可以根本不使用 $this 变量。 

上面的例子中,类 B 重新定义了函数 example()。A 类中原始定义的函数 example() 将被屏蔽并且不再生效,除非使用 :: 运算符来访问 A 类中的 example() 函数。如:A::example()(实际上,应该写为 parent::example(),下一章介绍该内容)。 

就此而论,对于当前对象,它可能有对象变量。因此可以在对象函数的内部使用 $this 和对象变量。 



------解决思路----------------------
调用Log这个对象的WirteLog这个静态方法,传7和$notice这两个参数过去

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn