Home  >  Article  >  Backend Development  >  php 引用一个函数?

php 引用一个函数?

WBOY
WBOYOriginal
2016-06-06 20:14:13967browse

<code>class c{
  function f1($parameter){

  }

  function f2(){
    $f = #如何获得f1的引用?
    $f($input);#为了这个
  }
}</code>

回复内容:

<code>class c{
  function f1($parameter){

  }

  function f2(){
    $f = #如何获得f1的引用?
    $f($input);#为了这个
  }
}</code>

$f=$this->f1();

少打了括号

<code><?php class c{
  function f1(){
        echo 'hello';
  }

  function f2(){
    $f = $this->f1();
    $f;
  }
}

$i =new c;

$i->f2();
</code>

<code>class c{
  function f1($parameter){

  }

  function f2(){
    $this->$f1($input);
  }
}</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn