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

search for in the

ReflectionParameter::export> <ReflectionParameter::__clone
[edit] Last updated: Fri, 24 May 2013

view this page in

ReflectionParameter::__construct

(PHP 5)

ReflectionParameter::__constructConstructeur

Description

public ReflectionParameter::__construct ( string $function , string $parameter )

Construit une nouvelle classe ReflectionParameter.

Avertissement

Cette fonction n'est pas documentée et seule la liste des arguments est disponible.

Liste de paramètres

function

La fonction depuis laquelle les paramètres sont reflétés.

parameter

Le paramètre.

Valeurs de retour

Aucune valeur n'est retournée.

Exemples

Exemple #1 Exemple avec ReflectionParameter

<?php
function foo($a$b$c) { }
function 
bar(Exception $a, &$b$c) { }
function 
baz(ReflectionFunction $a$b 1$c null) { }
function 
abc() { }

$reflect = new ReflectionFunction('foo');

echo 
$reflect;

foreach (
$reflect->getParameters() as $i => $param) {
    
printf(
        
"-- Parameter #%d: %s {\n".
        
"   Class: %s\n".
        
"   Allows NULL: %s\n".
        
"   Passed to by reference: %s\n".
        
"   Is optional?: %s\n".
        
"}\n",
        
$i// $param->getPosition() can be used from PHP 5.2.3
        
$param->getName(),
        
var_export($param->getClass(), 1),
        
var_export($param->allowsNull(), 1),
        
var_export($param->isPassedByReference(), 1),
        
$param->isOptional() ? 'yes' 'no'
    
);
}
?>

L'exemple ci-dessus va afficher quelque chose de similaire à :

Function [ <user> function foo ] {
  @@ /Users/philip/cvs/phpdoc/a 2 - 2

  - Parameters [3] {
    Parameter #0 [ <required> $a ]
    Parameter #1 [ <required> $b ]
    Parameter #2 [ <required> $c ]
  }
}
-- Parameter #0: a {
   Class: NULL
   Allows NULL: true
   Passed to by reference: false
   Is optional?: no
}
-- Parameter #1: b {
   Class: NULL
   Allows NULL: true
   Passed to by reference: false
   Is optional?: no
}
-- Parameter #2: c {
   Class: NULL
   Allows NULL: true
   Passed to by reference: false
   Is optional?: no
}

Voir aussi



add a note add a note User Contributed Notes ReflectionParameter::__construct - [1 notes]
up
0
tracid2008 t gmail o com
1 year ago
You also can use a class instead of a function name. Just use an array like that
<?php
$reflect
= new ReflectionParameter(array('className', 'methodName'), 'property');
?>

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