downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ReflectionParameter::getName> <ReflectionParameter::getDeclaringFunction
[edit] Last updated: Fri, 24 Jun 2011

view this page in

ReflectionParameter::getDefaultValue

(PHP 5 >= 5.0.3)

ReflectionParameter::getDefaultValueدریافت مقدار پیش‌فرص پارامتر

Description

public mixed ReflectionParameter::getDefaultValue ( void )

دریافت مقدار پیش‌فرص پارامتر برای تابع یا متد تعریف شده کاربر. اگر پارامتر اختیاری نباشد ReflectionException ایجاد خواهد شد.

Parameters

This function has no parameters.

Return Values

مقدار پیش‌فرض پارامتر.

Examples

Example #1 Getting

<?php
function foo($test$bar 'baz')
{
    echo 
$test $bar;
}

$function = new ReflectionFunction('foo');

foreach (
$function->getParameters() as $param) {
    echo 
'Name: ' $param->getName() . PHP_EOL;
    if (
$param->isOptional()) {
        echo 
'Default value: ' $param->getDefaultValue() . PHP_EOL;
    }
    echo 
PHP_EOL;
}
?>

The above example will output:

Name: test

Name: bar
Default value: baz

Notes

Note:

بدلیل جزئیات پیاده‌سازی مقدار پیش‌فرض توابع یا متدهای داخلی کلاس‌ها قابل دسترسی نیست. تلاش برای دسترسی آنها result a ReflectionException ایجاد خواهد کرد.

See Also



add a note add a note User Contributed Notes ReflectionParameter::getDefaultValue - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites