相关疑难解决方法(0)

新的自我与新的静态

我正在转换PHP 5.3库以在PHP 5.2上工作.支持我的主要方法是使用后期静态绑定return new static($options);,如果我将其转换为return new self($options)将得到相同的结果?

new self和之间有什么区别new static?

php static late-static-binding

483
推荐指数
3
解决办法
19万
查看次数

PHP:如何从父类调用子类的函数

如何从父类调用子类的函数?考虑一下:

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 inheritance

56
推荐指数
5
解决办法
8万
查看次数

PHP 5.2相当于后期静态绑定(新的静态)?

我试图在php 5.2服务器上创建一个为php 5.3构建的脚本.该脚本使用了许多后期静态绑定,如:

return new static($options);
Run Code Online (Sandbox Code Playgroud)

什么是在PHP 5.2中相当于这个?它会以某种方式成为新的自我吗?或者是不可能达到同样的效果......

谢谢

编辑:

这是一个相关的问题新自我与新静态

Juts试图绕过这个已经过时的静态绑定东西......

php late-static-binding

5
推荐指数
1
解决办法
1635
查看次数

标签 统计

php ×3

late-static-binding ×2

inheritance ×1

static ×1