📜  PHP | ReflectionFunction __toString()函数

📅  最后修改于: 2022-05-13 01:56:23.992000             🧑  作者: Mango

PHP | ReflectionFunction __toString()函数

ReflectionFunction::__toString()函数是PHP中的一个内置函数,用于返回指定函数的字符串表示形式。
句法:

string ReflectionFunction::__toString( void )

参数:此函数不接受任何参数。
返回值:此函数返回指定函数的字符串表示形式。
下面的程序说明了PHP中的 ReflectionFunction::__toString()函数:
方案一:

php
__toString();
 
// Getting the string representation of the
// above specified function
echo $A;
?>


php
__toString();
echo $function->__toString();
?>


输出:
Function [  function Company ] {
  @@ /home/a39c30763ecfc7f257d02e44de746b22.php 4 - 7

  - Parameters [2] {
    Parameter #0 [  $Company_Name ]
    Parameter #1 [  $Role ]
  }
}

方案二:

PHP

__toString();
echo $function->__toString();
?>
输出:
Function [  function Trial2 ] {
  @@ /home/09f598906ca0bfcad4613b5dea41c27b.php 9 - 12

  - Parameters [2] {
    Parameter #0 [  $First_Args ]
    Parameter #1 [  $Second_Args ]
  }
}
Function [  function Trial2 ] {
  @@ /home/09f598906ca0bfcad4613b5dea41c27b.php 9 - 12

  - Parameters [2] {
    Parameter #0 [  $First_Args ]
    Parameter #1 [  $Second_Args ]
  }
}

参考: https://www. PHP.net/manual/en/reflectionfunction.tostring。 PHP