Php “:”语法是什么意思?
可能重复: 在PHP中::是什么意思?e、 gPhp “:”语法是什么意思?,php,fuelphp,Php,Fuelphp,可能重复: 在PHP中::是什么意思?e、 g Pagination::set_config($config); 它类似于=>?它被称为范围解析运算符 :在C++中,最初命名为范围解析操作符的意思是将这些TexIn配置文件$ CONFIG方法与类分页关联起来。它是一个静态方法,不能通过它的类的对象访问静态方法,因为它们与它们的类相关联,而不是与该类的对象相关联 Pagination::set_config($config); 符号->用于访问实例成员。在PHP中,符号=>与关联数组一起使用
Pagination::set_config($config);
它类似于=>?它被称为范围解析运算符 <>:在C++中,最初命名为范围解析操作符的意思是将这些TexIn配置文件$ CONFIG方法与类分页关联起来。它是一个静态方法,不能通过它的类的对象访问静态方法,因为它们与它们的类相关联,而不是与该类的对象相关联
Pagination::set_config($config);
符号->用于访问实例成员。在PHP中,符号=>与关联数组一起使用,以访问这些数组的成员。在PHP中,它是。它用于访问未初始化类的方法和属性。为此表示法显式化的方法称为静态方法
此外,您可以使用此表示法从您所在的位置相对地遍历扩展类。例如:
class betterClass extends basicClass {
protected function doTheMagic() {
$result = parent::doTheMagic();
echo "this will output the result: " . $result;
return $result;
}
}
在本例中,doTheMagic方法覆盖其父级的现有方法,但使用parent::doTheMagic;但是,可以调用原始方法。此::-语法称为范围解析运算符
它用来指基类或还没有实例的类中的函数和变量
来自php.net的示例:
<?php
class A {
function example() {
echo "I am the original function A::example().<br />\n";
}
}
class B extends A {
function example() {
echo "I am the redefined function B::example().<br />\n";
A::example();
}
}
// there is no object of class A.
// this will print
// I am the original function A::example().<br />
A::example();
// create an object of class B.
$b = new B;
// this will print
// I am the redefined function B::example().<br />
// I am the original function A::example().<br />
$b->example();
?>
请阅读示例中的注释。有关详细信息,请转到。的名称::is Paamayim Nekudotayim。@戈登-谢谢你-搜索框中的各种搜索都无法回答我的问题。@ThinkingMonkey-我没有投你反对票!我确实搜索过。。。只是没有找到合适的术语。那么道歉吧