PHP 5.4.33 Released

ReflectionFunction::__construct

(PHP 5)

ReflectionFunction::__constructساخت شی ReflectionFunction

Description

ReflectionFunction::__construct ( string $name )

ساخت شی ReflectionFunction.

Parameters

name

نام تابع برای بازتاب.

Return Values

No value is returned.

Errors/Exceptions

ReflectionException اگر پارامتر name شامل تابع صحیح نباشد.

Examples

Example #1 مثال ReflectionFunction::__construct()

<?php
/**
 * A simple counter
 *
 * @return    int
 */
function counter()
{
    static 
$c 0;
    return ++
$c;
}

// Create an instance of the ReflectionFunction class
$func = new ReflectionFunction('counter');

// Print out basic information
printf(
    
"===> The %s function '%s'\n".
    
"     declared in %s\n".
    
"     lines %d to %d\n",
    
$func->isInternal() ? 'internal' 'user-defined',
    
$func->getName(),
    
$func->getFileName(),
    
$func->getStartLine(),
    
$func->getEndline()
);

// Print documentation comment
printf("---> Documentation:\n %s\n"var_export($func->getDocComment(), 1));

// Print static variables if existant
if ($statics $func->getStaticVariables())
{
    
printf("---> Static variables: %s\n"var_export($statics1));
}
?>

The above example will output something similar to:

===> The user-defined function 'counter'
     declared in /Users/philip/test.php
     lines 7 to 11
---> Documentation:
 '/**
 * A simple counter
 *
 * @return    int
 */'
---> Static variables: array (
  'c' => 0,
)

See Also

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top