略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ReflectionParameter::isDefaultValueConstant

2024-12-22

ReflectionParameter::isDefaultValueConstant

(PHP 5 >= 5.4.6, PHP 7, PHP 8)

ReflectionParameter::isDefaultValueConstantReturns whether the default value of this parameter is a constant

说明

public ReflectionParameter::isDefaultValueConstant(): bool

Returns whether the default value of this parameter is a constant.

参数

此函数没有参数。

返回值

Returns true if the default value is constant, and false otherwise.

参见

add a noteadd a note

User Contributed Notes 1 note

up
2
kristianoye at gmail dot com
7 years ago
This method returns true only if the parameter's default value is set to a named constant.  e.g.

class Foo {
   const OPTION_MULTIGET = 1;

   //Method 1
   public function setGetOptions($opts=0);

   //Method 2
   public function setMultiGetOptions($opts=Foo::OPTION_MULTIGET);
}

Method 1's first ReflectionParameter will return isDefaultValueConstant() = false (0 is a "constant"/static value but not a named constant) and Method 2's will return isDefaultValueConsntant() = true.

官方地址:https://www.php.net/manual/en/reflectionparameter.isdefaultvalueconstant.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3