PHP Unconference Europe 2015

ReflectionFunctionAbstract::getNumberOfRequiredParameters

(PHP 5 >= 5.0.3)

ReflectionFunctionAbstract::getNumberOfRequiredParametersGets number of required parameters

Beschreibung

public int ReflectionFunctionAbstract::getNumberOfRequiredParameters ( void )

Get the number of required parameters that a function defines.

Warnung

Diese Funktion ist bis jetzt nicht dokumentiert. Es steht nur die Liste der Argumente zur Verf├╝gung.

Parameter-Liste

Diese Funktion hat keine Parameter.

R├╝ckgabewerte

The number of required parameters.

Siehe auch

add a note add a note

User Contributed Notes 1 note

up
1
sebastian at sebastian-eiweleit dot de
1 year ago
<?php
namespace ExampleWorld;
// The Class
class helloWorld {
   
/* Method with two required arguments */

   
public function requiredTwoArguments ( $var1, $var2 ) {
       
// Some code ...
   
}

   
/* Method with two arguments, but just one is required */
   
public function requiredOneArgument ( $var1, $var2 = false ) {
       
// Some code ...
   
}
}

$r = new \ReflectionMethod ( 'ExampleWorld\helloWorld', 'requiredTwoArguments' );
echo
$r->getNumberOfRequiredParameters ();

$r = new \ReflectionMethod ( 'ExampleWorld\helloWorld', 'requiredOneArgument' );
echo
$r->getNumberOfRequiredParameters ();

// Output: 2 1
To Top