我正在转换PHP 5.3库以在PHP 5.2上工作.支持我的主要方法是使用后期静态绑定return new static($options);,如果我将其转换为return new self($options)将得到相同的结果?
new self和之间有什么区别new static?
如何从父类调用子类的函数?考虑一下:
class whale
{
function __construct()
{
// some code here
}
function myfunc()
{
// how do i call the "test" function of fish class here??
}
}
class fish extends whale
{
function __construct()
{
parent::construct();
}
function test()
{
echo "So you managed to call me !!";
}
}
Run Code Online (Sandbox Code Playgroud) 我试图在php 5.2服务器上创建一个为php 5.3构建的脚本.该脚本使用了许多后期静态绑定,如:
return new static($options);
Run Code Online (Sandbox Code Playgroud)
什么是在PHP 5.2中相当于这个?它会以某种方式成为新的自我吗?或者是不可能达到同样的效果......
谢谢
编辑:
这是一个相关的问题新自我与新静态
Juts试图绕过这个已经过时的静态绑定东西......