本文整理汇总了PHP中Reflection::GetClosure方法的典型用法代码示例。如果您正苦于以下问题:PHP Reflection::GetClosure方法的具体用法?PHP Reflection::GetClosure怎么用?PHP Reflection::GetClosure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reflection
的用法示例。
在下文中一共展示了Reflection::GetClosure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReflectionTest
/**
* Reflection function test
* Used to test Reflection class
*/
public function ReflectionTest()
{
echo "<h2>Testing function: ReflectionTest </h2>";
/**
* The reflection example class object is created
* It provides the test function
* This will be the users class
*/
include_once 'ReflectionExampleClass.php';
$reflection_example = new ReflectionExampleClass();
/**
* The function that provides custom validation for the test function parameters
* It signals an error if the length of the random string is larger than 80 characters
*/
$custom_validation_callback = array($reflection_example, "CustomValidation");
/** The safe_function_caller closure is fetched from the Reflection class */
$safe_function_caller = Reflection::GetClosure();
/** The parameters for the test function */
$parameters = array("number1" => 30, "number2" => 10, "number3" => 10, "data" => array("type" => "integer", "random_string" => "<b style='text-align:center'>The result of adding the three integers is: </b>"));
/** The current application context */
$context = "browser";
/** The test function is called through the safe function caller */
$result = $safe_function_caller($reflection_example, "AddNumbers", $parameters, $context, $custom_validation_callback);
/** The result of adding the numbers is displayed */
echo $result['random_string'] . $result['sum'];
}
示例2: error_reporting
<?php
namespace Framework\Utilities;
error_reporting(E_ALL);
ini_set("display_errors", 1);
include 'ReflectionExampleClass.php';
try {
/** The reflection example class object is created. It provides the test function */
$reflection_example = new ReflectionExampleClass();
/** The function that provides custom validation for the test function parameters. It signals an error if the length of the random string is larger than 80 characters */
$custom_validation_callback = array($reflection_example, "CustomValidation");
/** The safe_function_caller closure is fetched from the Reflection class */
$safe_function_caller = Reflection::GetClosure();
/** The parameters for the test function */
$parameters = array("number1" => 30, "number2" => 10, "number3" => 10, "data" => array("type" => "integer", "random_string" => "<b style='text-align:center'>The result of adding the three integers is: </b>"));
/** The current application context */
$context = "browser";
/** The test function is called through the safe function caller */
$result = $safe_function_caller($reflection_example, "AddNumbers", $parameters, $context, $custom_validation_callback, $context);
/** The result of adding the numbers is displayed */
echo $result['random_string'] . $result['sum'];
} catch (\Exception $e) {
die($e->getMessage());
}